{"id":7353,"date":"2023-01-25T09:37:46","date_gmt":"2023-01-25T07:37:46","guid":{"rendered":"https:\/\/store.algosyntax.com\/?post_type=asx-lms-tutorial-cpt&#038;p=7353"},"modified":"2026-03-09T11:31:34","modified_gmt":"2026-03-09T09:31:34","slug":"ue5-methods-to-mask-objects-using-material-editor","status":"publish","type":"asx-lms-tutorial-cpt","link":"https:\/\/store.algosyntax.com\/tutorials\/unreal-engine\/ue5-methods-to-mask-objects-using-material-editor\/","title":{"rendered":"UE5 Opacity Mask In The Material Editor With Rotation"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"7353\" class=\"elementor elementor-7353\" data-elementor-post-type=\"asx-lms-tutorial-cpt\">\n\t\t\t\t<div class=\"elementor-element elementor-element-278f840 e-con-full e-flex e-con e-parent\" data-id=\"278f840\" data-element_type=\"container\" data-e-type=\"container\">\n\t\t\t\t<div class=\"elementor-element elementor-element-9a8ea1d elementor-widget elementor-widget-text-editor\" data-id=\"9a8ea1d\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>In this article, we will explore various methods to mask objects using the Material Editor in Unreal Engine 5 (UE5).<\/p><p>\u00a0<\/p><p>Masking is a powerful technique that allows developers to hide or reveal certain parts of an object or scene, and can be used for a variety of purposes, such as creating special effects, hiding invisible collision meshes, or creating more detailed and realistic environments.<\/p><p>\u00a0<\/p><p>Whether you are a beginner or an experienced developer, this article will provide you with the knowledge and tools you need to mask objects in UE5 like a pro.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8f24c3e elementor-widget elementor-widget-heading\" data-id=\"8f24c3e\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Simple Masking On A Single Axis<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3240881 elementor-widget elementor-widget-text-editor\" data-id=\"3240881\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>The simplest way and setup is to mask the portion of the object that crosses a certain threshold in any of the three axis X,Y,Z.\u00a0<br \/><br \/>For this tutorial, Let&#8217;s assume we want to make some part of the mesh invisible when it crosses our Z threshold. Eg Any part of the mesh that&#8217;s lower than 20 Units in World Space should be invisible or masked out.<br \/><br \/>In this scenario, Z is our axis, and 20 is the threshold. Anything above 20 in world space will be visible.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-5cccd26 elementor-widget elementor-widget-text-editor\" data-id=\"5cccd26\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<ol><li><h3>Creating\u00a0The Material<\/h3><\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d8eba21 elementor-widget elementor-widget-text-editor\" data-id=\"d8eba21\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Most of the work will be done by the material that will be applied to the Mesh we want to mask. For this to work, we must set our material <strong>Blend Mode\u00a0<\/strong>to &#8220;<strong>Masked&#8221;<\/strong>. This is so that we can get access to the &#8220;<strong>Opacity Mask<\/strong>&#8221; output.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e2d9c76 elementor-widget elementor-widget-image\" data-id=\"e2d9c76\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img fetchpriority=\"high\" decoding=\"async\" width=\"810\" height=\"162\" src=\"https:\/\/store.algosyntax.com\/wp-content\/uploads\/tutorials\/unreal-engine\/enable-opacity-mask-ue5.png\" class=\"attachment-large size-large wp-image-7365\" alt=\"Enable Opacity Mask UE5\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e6f3122 elementor-widget elementor-widget-heading\" data-id=\"e6f3122\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\">The Opacity Mask<\/h4>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8054837 elementor-widget elementor-widget-text-editor\" data-id=\"8054837\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>The &#8220;Opacity Mask&#8221; is a feature in the Material Editor of Unreal Engine 5 (UE5) that allows developers to mask specific parts of an object by controlling its transparency. This is achieved by submitting a value of 0.0 or 1.0 where 0 represents fully transparent areas and 1.0 represents fully opaque (visbible) areas.<br \/><br \/><strong>NB: Keep in mind we are working in per pixel terms (of the material), meaning we can set a different value per pixel depending on the math we do before submitting the value.<\/strong><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7afb57b elementor-widget elementor-widget-heading\" data-id=\"7afb57b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\">The Absolute World Position Node<\/h4>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-681fcde elementor-widget elementor-widget-text-editor\" data-id=\"681fcde\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>The &#8220;Absolute World Position&#8221; node in the Material Editor of Unreal Engine 5 (UE5) is a node that outputs the absolute <strong>world position<\/strong> of a <strong>pixel<\/strong> on a mesh in the scene. This means we can check if the pixel is below 20 Z units in world space. If it&#8217;s below 20 Z-Unitz we set it to <strong>invisible<\/strong> by setting the <strong>opacity mask value<\/strong> to 0. Simple right?<\/p><p>\u00a0<\/p><p>To do this &#8220;IF x, then y&#8221; comparison we need to use the Material Editor &#8220;IF&#8221; node. This &#8220;If&#8221; node outputs a different value, 0 or 1 in our case , depending on the Z axis of the pixel.<br \/><br \/><strong>NB: To get the Z-axis value of the pixel, we can use the Component Mask node.<\/strong><\/p><p>\u00a0<\/p><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-3f837c6 elementor-widget elementor-widget-image\" data-id=\"3f837c6\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"image.default\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<img decoding=\"async\" width=\"697\" height=\"267\" src=\"https:\/\/store.algosyntax.com\/wp-content\/uploads\/tutorials\/unreal-engine\/absolute-world-position-node-unreal-engine.png\" class=\"attachment-full size-full wp-image-7373\" alt=\"\" \/>\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d114ba7 elementor-widget elementor-widget-text-editor\" data-id=\"d114ba7\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p><strong>It&#8217;s important to remember the B value or &#8220;20&#8221; in this case can be set by blueprints by changing it into a parameter that can be set by using Dynamic Material Instances.\u00a0<br \/><br \/><\/strong>This means you can have an arbitrary Z value threshold that can be set by game events\/ procedurally.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ef02732 elementor-widget elementor-widget-text-editor\" data-id=\"ef02732\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<ol start=\"2\"><li><h3>Setting Mask Point from Blueprints<\/h3><\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-42812f2 elementor-widget elementor-widget-text-editor\" data-id=\"42812f2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>This section is optional. From step 1 above, if you apply your material to a mesh and it goes under 20 z units, it will be masked. The following is just a suggestion on how to control this cutoff or threshold point from Blueprints.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-d392c25 elementor-widget elementor-widget-heading\" data-id=\"d392c25\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h4 class=\"elementor-heading-title elementor-size-default\">Material Parameter Collection vs Normal Parameters<\/h4>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-ccfd120 elementor-widget elementor-widget-text-editor\" data-id=\"ccfd120\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Material Parameter Collection allows you to group and control multiple parameters as a single unit, and it can be shared among multiple materials, which can be very useful for situations where multiple materials need to share the same parameter value. While Normal Parameters are specific to a single material and can be used to control various aspects of the material.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7af1dce elementor-widget elementor-widget-text-editor\" data-id=\"7af1dce\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Whatever approach you choose does not matter, just make sure you reference the parameter in the material and in the blueprint. You can then set this paramater on begin play or on tick depending on your project&#8217;s demands.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a54eeb5 elementor-widget elementor-widget-heading\" data-id=\"a54eeb5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Opacity Mask With Rotation<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-72391d5 elementor-widget elementor-widget-text-editor\" data-id=\"72391d5\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Sometimes you wish to take the Rotation of objects into consideration when masking.\u00a0 The simplest way to do this is to use the Forward Vector of an Actor\/Object. You then just check if Absolute World Position is in front or behind the object\/acotor by use of the Dot product.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-c1d2c34 elementor-widget elementor-widget-text-editor\" data-id=\"c1d2c34\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<h3>Check If Absolute World Position is in front or behind The Objects Forward Vector.<\/h3>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-7a1a538 elementor-widget elementor-widget-text-editor\" data-id=\"7a1a538\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p><strong>Keep in mind you can pass in the Forward Vector Position and Actor Position from Blueprints to the Material Editor through the use of Material Parameters.\u00a0<\/strong><\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-b7bb8b2 elementor-widget elementor-widget-text-editor\" data-id=\"b7bb8b2\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>To check if the <strong>absolute world position<\/strong> is behind or in front of the forward vector, you can calculate the <strong>dot product<\/strong> between <strong>the forward vector<\/strong> and the vector pointing from the <strong>object&#8217;s position<\/strong> to the <strong>absolute world position<\/strong>. The dot product will give you a scalar value that represents the angle between the two vectors.<\/p><p>Here&#8217;s the general idea:<\/p><ol><li><p>Calculate the vector pointing from the object&#8217;s position to the pixel world position. You can do this by subtracting the object&#8217;s position from the point&#8217;s position.<\/p><\/li><li><p>Normalize both the forward vector and the vector pointing from the object&#8217;s position to the point.<\/p><\/li><li><p>Calculate the dot product between the two normalized vectors.<\/p><\/li><li><p>If the dot product is positive, it means the point is in front of the object. If the dot product is negative, it means the point is behind the object. If the dot product is zero, it means the point is perpendicular to the forward vector.<\/p><\/li><\/ol>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-45ecac1 elementor-widget elementor-widget-text-editor\" data-id=\"45ecac1\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>You can then add either an IF node or custom node that returns either 1 or 0 (the mask) depending on if the Dot Product is positive or negative. Plug the result of this if condition into the Opacity Mask.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-98e85ec elementor-widget elementor-widget-heading\" data-id=\"98e85ec\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h2 class=\"elementor-heading-title elementor-size-default\">Opacity Mask Using Box Mask 3D<\/h2>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-150757b elementor-widget elementor-widget-text-editor\" data-id=\"150757b\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>The Material Editor has a Box Mask 3D\u00a0 Node. You can use this to drive a mask. The concept is simple.\u00a0<\/p><p><br \/>We have a point\/position, and we draw a 3D BOX in World Space. We then check if this point is within this 3D Box. If it is in, the BOX Mask 3D node will return 1.0 or true, if not, it will return 0.<\/p><p>\u00a0<\/p><p>Simple right? This means we can check if our Absolute World Position is in this area and then chose if we want to make it or not.<\/p><p>\u00a0<\/p><p>The box mask 3d node has the following inputs: A,B ,Bounds and falloff.<\/p><p>\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-719bb90 elementor-widget elementor-widget-text-editor\" data-id=\"719bb90\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>The box mask 3d node has the following inputs: A,B ,Bounds and falloff.<\/p><p>\u00a0<\/p><p>The <strong>&#8220;A&#8221;<\/strong> is the position you want to check\/verify if it&#8217;s within the box.<\/p><p>&#8220;<strong>B&#8221;<\/strong> is the origin or start position of the box.<\/p><p>&#8220;<strong>Bounds<\/strong>&#8220;, is the size of the box. I.e we start from B and apply the size and we have a box.<\/p><p><strong>Falloff<\/strong> is like a border radius for the box, you can soften the edges of the box.<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-cf50498 elementor-widget elementor-widget-text-editor\" data-id=\"cf50498\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>You&#8217;ll usually witness developers doing a 1-minus from the result of the Box Mask 3D. This simply inverting the result. That is, convert trues to false and false to true. Depends on your use case of the box mask result.\u00a0 You can even replace it with an IF node or a custom node with If conditions that return a specific result.\u00a0<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"featured_media":0,"template":"","asx-lms-tutorial-categories":[45,74],"asx-lms-tutorial-tags":[75],"class_list":["post-7353","asx-lms-tutorial-cpt","type-asx-lms-tutorial-cpt","status-publish","hentry","asx-lms-tutorial-categories-unreal-engine","asx-lms-tutorial-categories-materials","asx-lms-tutorial-tags-materials","entry"],"acf":[],"_links":{"self":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/7353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt"}],"about":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/types\/asx-lms-tutorial-cpt"}],"version-history":[{"count":0,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-cpt\/7353\/revisions"}],"wp:attachment":[{"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/media?parent=7353"}],"wp:term":[{"taxonomy":"asx-lms-tutorial-categories","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-categories?post=7353"},{"taxonomy":"asx-lms-tutorial-tags","embeddable":true,"href":"https:\/\/store.algosyntax.com\/asx-rest\/wp\/v2\/asx-lms-tutorial-tags?post=7353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}