{"id":1163,"date":"2025-09-26T18:28:04","date_gmt":"2025-09-26T22:28:04","guid":{"rendered":"https:\/\/willkolb.com\/?p=1163"},"modified":"2025-09-26T18:28:04","modified_gmt":"2025-09-26T22:28:04","slug":"how-not-to-use-materials-in-unreal","status":"publish","type":"post","link":"https:\/\/willkolb.com\/?p=1163","title":{"rendered":"How (Not) to use materials in unreal"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"193\" height=\"117\" src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-34.png\" alt=\"\" class=\"wp-image-1174\"\/><figcaption class=\"wp-element-caption\">hell yeah<\/figcaption><\/figure>\n\n\n\n<p>The borderlands 4 issues with unreal (see: <a href=\"https:\/\/www.pcgamer.com\/games\/fps\/borderlands-4s-latest-patch-triggers-a-flurry-of-performance-complaints-but-gearbox-says-new-stuttering-problems-should-resolve-over-time-as-the-shaders-continue-to-compile\/\">https:\/\/www.pcgamer.com\/games\/fps\/borderlands-4s-latest-patch-triggers-a-flurry-of-performance-complaints-but-gearbox-says-new-stuttering-problems-should-resolve-over-time-as-the-shaders-continue-to-compile\/<\/a> ) made me realize I was doing all of my materials wrong.<\/p>\n\n\n\n<p>Originally the way I pulled in 3d meshes generated a material of each slot in the mesh. So I thougth I was being clever by using material slots to determine colors (so I didn&#8217;t have to texture paint), however the issue above made me actual look into things. So I was taking materials for granted as things that were inherent to unreal, however materials themselves are nothing more than giant HLSL files (see <a href=\"https:\/\/en.wikipedia.org\/wiki\/High-Level_Shader_Language\">https:\/\/en.wikipedia.org\/wiki\/High-Level_Shader_Language<\/a>). This means that every material I made has to be complied for whatever graphics hardware the user is using (which is the borderlands 4 problem from the article above.) The solution is to use material instances (see <a href=\"https:\/\/dev.epicgames.com\/documentation\/en-us\/unreal-engine\/creating-and-using-material-instances-in-unreal-engine\">https:\/\/dev.epicgames.com\/documentation\/en-us\/unreal-engine\/creating-and-using-material-instances-in-unreal-engine<\/a>)! These are parameterized unreal materials which allow for the developer to expose parameters into compiled base materials so we dont have to deal with as much shader compiling.<\/p>\n\n\n\n<p>Sooo from just imports and optimized development had 30-40 plus materials which would come from asset imports, most I could categorize into:<\/p>\n\n\n\n<p>-Painted Metal<br>-Exposed Metal<br>-Wood<br>-Plastic<br>-Rubber<br>-Concrete<br>-Brick<br>-Glass<br><\/p>\n\n\n\n<p>So instead of 30-40 compilations for all of the materials I could whiddle things down to 8 compilations to save myself from making the user wait with no colors on their screen. After 30 painstaking minutes I was able to remove all other materials (minus a few specialized ones) to the 8 materials above and instances thereof. <\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"386\" src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-29-1024x386.png\" alt=\"\" class=\"wp-image-1165\" srcset=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-29-1024x386.png 1024w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-29-300x113.png 300w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-29-768x289.png 768w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-29-500x188.png 500w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-29.png 1369w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><br>Now things look a little shinier and more visually consistent<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"673\" height=\"455\" src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-31.png\" alt=\"\" class=\"wp-image-1167\" srcset=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-31.png 673w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-31-300x203.png 300w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-31-444x300.png 444w\" sizes=\"auto, (max-width: 673px) 100vw, 673px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"668\" height=\"341\" src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-30.png\" alt=\"\" class=\"wp-image-1166\" srcset=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-30.png 668w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-30-300x153.png 300w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-30-500x255.png 500w\" sizes=\"auto, (max-width: 668px) 100vw, 668px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"638\" src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-28-1024x638.png\" alt=\"\" class=\"wp-image-1164\" srcset=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-28-1024x638.png 1024w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-28-300x187.png 300w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-28-768x479.png 768w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-28-481x300.png 481w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-28.png 1043w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The side effect that I wasn&#8217;t expecting is that the game is now BLAZING FAST. I went from around 60-70 fps on light load and 40-50 on heavy load on average to pretty much locking to 120fps in light load and 80fps in high load. I had plans to re-write how I handle some of the animation data transferring but I&#8217;m thinking now that might not be needed.<\/p>\n\n\n\n<p>I also did some work on the ai so they stayed a bit more mobile. I also added recoil to the bots<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1920 \/ 1080;\" width=\"1920\" controls src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/2025-09-26_18-18-43.mp4\"><\/video><\/figure>\n\n\n\n<p>Also bots now have a pitch when aiming:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1920 \/ 1080;\" width=\"1920\" controls src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/2025-09-26_18-20-30.mp4\"><\/video><\/figure>\n\n\n\n<p>Finally I added in weapon switching via the num keys:<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video height=\"1080\" style=\"aspect-ratio: 1920 \/ 1080;\" width=\"1920\" controls src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/2025-09-26_18-21-15.mp4\"><\/video><\/figure>\n\n\n\n<p>I want to add a half-life style cross selection bar but that will probably happen later with another hud pass.<\/p>\n\n\n\n<p>The gameplay test map has now gone from a placeholder dev map to a low effort source engine map:<br><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"653\" src=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-32-1024x653.png\" alt=\"\" class=\"wp-image-1172\" srcset=\"https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-32-1024x653.png 1024w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-32-300x191.png 300w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-32-768x490.png 768w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-32-471x300.png 471w, https:\/\/willkolb.com\/wp-content\/uploads\/2025\/09\/image-32.png 1211w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>The whole level I would argue is pretty bad for gameplay also the only thing I want to add is some rain effects just to get a vibe then I&#8217;ll move onto a kind of multi-lane style of map.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The borderlands 4 issues with unreal (see: https:\/\/www.pcgamer.com\/games\/fps\/borderlands-4s-latest-patch-triggers-a-flurry-of-performance-complaints-but-gearbox-says-new-stuttering-problems-should-resolve-over-time-as-the-shaders-continue-to-compile\/ ) made me realize I was doing all of my materials wrong. Originally the way I pulled in 3d meshes generated a material of each slot in the mesh. So I thougth I was being clever by using material slots to determine colors (so I didn&#8217;t have [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1174,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,9],"tags":[],"class_list":["post-1163","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-gamedev","category-unreal"],"_links":{"self":[{"href":"https:\/\/willkolb.com\/index.php?rest_route=\/wp\/v2\/posts\/1163","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/willkolb.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/willkolb.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/willkolb.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/willkolb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1163"}],"version-history":[{"count":2,"href":"https:\/\/willkolb.com\/index.php?rest_route=\/wp\/v2\/posts\/1163\/revisions"}],"predecessor-version":[{"id":1175,"href":"https:\/\/willkolb.com\/index.php?rest_route=\/wp\/v2\/posts\/1163\/revisions\/1175"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/willkolb.com\/index.php?rest_route=\/wp\/v2\/media\/1174"}],"wp:attachment":[{"href":"https:\/\/willkolb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1163"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/willkolb.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1163"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/willkolb.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1163"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}