ไม่สามารถเล่นวิดีโอนี้
ขออภัยในความไม่สะดวก

UE5: Interactive Materials in Blueprint // Unreal Engine Tutorial

แชร์
ฝัง
  • เผยแพร่เมื่อ 12 ส.ค. 2024
  • Support on Patreon: / techartaid
    Streaming weekly at / techartaid
    Learn how to control materials in Blueprint. Animate properties by sending data from gameplay. Optimize performance by avoiding draw calls. Set scalar and vector parameters on hundreds of meshes efficiently, without dynamic material instances.
    00:00 Introduction
    01:30 Material parameters & instances
    04:05 Dynamic material instance in Blueprint
    05:25 Performance issue: Draw calls from dynamic instances
    07:38 Optimization: Custom primitive data
    10:02 Set mesh color (custom primitive data) in Blueprint
    14:36 How to fix default black in custom primitive data
    18:06 Controlling an array of meshes together
    20:17 Use 0-1 value range for convenience
    21:09 Controlling emissive material
    22:59 Animating rotation
    24:10 Global color switch: Material Parameter Collection
    26:39 Using global parameters in materials
    27:48 Final words

ความคิดเห็น • 72

  • @TechArtAid
    @TechArtAid  3 ปีที่แล้ว +27

    Hello again ;]

    • @maniacb0y
      @maniacb0y 3 ปีที่แล้ว

      Welcome back! We missed you.

    • @LuisFrontanilla
      @LuisFrontanilla 3 ปีที่แล้ว +1

      HELOOOOOOO

    • @dawidbujak
      @dawidbujak 3 ปีที่แล้ว +1

      Jak zawsze świetne wideo, szkoda że nie postujesz częściej

    • @Pharoah1224
      @Pharoah1224 3 ปีที่แล้ว

      How does lumen change the order of operations presented in this video?

    • @TechArtAid
      @TechArtAid  3 ปีที่แล้ว +2

      Lumen is perfectly compatible, fortunately! See my new video about Lumen. It's the same map. I'm wondering about Nanite though - how does it handle custom primitive data. I'd have to test.

  • @musicdudem6673
    @musicdudem6673 3 ปีที่แล้ว +5

    This is a fantastic exercise and video
    Sometimes you get so caught up in technical things, fighting the lack of educational materials or fighting through too much at times, sometimes learning things can be so daunting and exhausting
    And then every once in awhile there's a tutorial that captures the simplicity, magic and imagination of a world that drew us in as kids, and reminds us we can JUST HAVE FUN and enjoy the process sometimes
    Great vid

  • @maniacb0y
    @maniacb0y 3 ปีที่แล้ว +11

    I'm a simple person, I see Technical Art I press like.

    • @maniacb0y
      @maniacb0y 3 ปีที่แล้ว +4

      And btw, great topic Custom Primitive Data, a very little used feature that is actually very powerful.

    • @TechArtAid
      @TechArtAid  3 ปีที่แล้ว +8

      I thought so too! We used it extensively in Cyberpunk 2077. Vehicle damage, glass bullethole positions, wetness.

  • @cg-jm1736
    @cg-jm1736 3 ปีที่แล้ว +3

    Super cool 😎 I discovered your channel just like half a year ago and thought already this is more of a passive lookup channel for me, rather than an active video source. So cool you decided to upload a video again!

  • @koljak9395
    @koljak9395 ปีที่แล้ว +1

    Man, I think you just saved my day! Been digging around the internet for hours searching for such a way to animate materials. Thanks!

  • @Daniel-be6cj
    @Daniel-be6cj 2 ปีที่แล้ว +2

    The Custom Primitive Data optimization was brilliant! I had no idea about that optimization. Thank you so much!

  • @brunskiy
    @brunskiy 6 หลายเดือนก่อน +1

    Cool. Thanks. You can wrap the parameter setting code in a function and call it in Construction Script. Then the colors will be visible in the Editor.

  • @jonathanxdoe
    @jonathanxdoe 3 ปีที่แล้ว +3

    Nice to see you again!

  • @Fafmagic
    @Fafmagic 3 ปีที่แล้ว +1

    Custom Primitive Data - mind blown... thanks so much for this

  • @emanuelerusso5710
    @emanuelerusso5710 3 ปีที่แล้ว +1

    it's great to see you back, your tutorials are very complete and useful

  • @LuisFrontanilla
    @LuisFrontanilla 3 ปีที่แล้ว +2

    The Custom Primitive data stuff is awesome! thanks for the tutorial :3

  • @amigoface
    @amigoface 3 ปีที่แล้ว +1

    hey, it has been a while !
    good to see u again dude .

  • @billmore6486
    @billmore6486 ปีที่แล้ว

    This is how you make a tutorial.
    Thankyou for the video! I learned alot. Also this efffect looks amazing, reminds me of classic 3d platformers back in the day.

  • @turalmemmedov3648
    @turalmemmedov3648 3 ปีที่แล้ว +1

    I my GOD!!!! You are BACKKKK YYAYAYYYYAYYYYYYYY!!!!!!

  • @Azer0sz
    @Azer0sz 3 ปีที่แล้ว +1

    Wow, incredible video, thank you!

  • @PixelsLaboratory
    @PixelsLaboratory ปีที่แล้ว +1

    At 02:39 you said we definitely need a MID (Material Instance Dynamic), because the regular editor-based MIC (Material Instance Constant) cannot be changed at runtime, during gameplay, because it becomes "cooked". The official UE documentation says the exact same thing. However, on my latest video you'll see that I am able to control everything, at runtime, for each individual material, without using any instancing at all, no matter if it's MIC or MID. And yes, I even tried it on a fully exported game with "Shipping" settings and "By the Book" cooking and it still works! I'm actually using the exact node you said not to use at 25:58. I know you were already explaining something completely different there, but just as a reference. So, I fully understood the CPD and MPC roles and that whole separate discussion, but my biggest issue is trying to understand why am I able to control things at runtime, in a cooked game, by using the base (parent) material itself directly, without any Dynamic instancing at all, even without regular (Constant) instancing? Thanks so much for your videos, btw!!!

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว +1

      Interesting! Thanks for sharing. What happens if this material is multiple times throughout the level? Are all its instances being changed at once?

    • @PixelsLaboratory
      @PixelsLaboratory ปีที่แล้ว

      ​@@TechArtAid Nope, all are being changed individually, like shown in my video (I'm using 2x objects there to demonstrate this and you can see their parameters being controlled differently in real-time). Also, nobody on the UE forums seems to have any idea (the link is in my vid's description), despite veteran members confirming that it works like that since the early days of UE4. This makes me question everything, since I cannot understand why the creators of UE would make this entire system of nodes for creating MIDs, if they actually were never needed at all in the first place. It completely invalidates their documentation.

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว

      Check the number of draw calls please. It should increase, indicating a creation of a MID under the hood. One idea that comes to my mind is that MIDs can be passed (and stored) as a reference. That makes them reusable if you need to, configurable later etc.

    • @PixelsLaboratory
      @PixelsLaboratory ปีที่แล้ว

      ​@@TechArtAid So, after many tests, I can clearly state that my draw calls are *exactly the same* using 3x methods (changing the material directly vs. doing it through the use of an MID vs. not changing anything and just having a simple, static material from the Engine Content), which further makes zero sense since I was hoping this would be the hidden reason for why MIDs would be better, but apparently it still fails to add no value at all. Not only that, but when using MIDs, if I have multiple Static Meshes inside the same BP, all of them are now in-sync with respect to their parameter changes because although I'm still giving separate data to each of them, they're all using the same MID, therefore they all take the combined changes at once, meaning I cannot independently change them at will the way I'm able to when *not* using MIDs. This clearly shows me that when I'm not using MIDs, somehow UE is able to understand that I wish to have separate behavior for each Static Mesh and manages to somehow keep that separation behind the scenes, while creating an MID by myself will clearly use *that* MID only for all Static Meshes, since that's what I'm telling it to do. I'm really not satisfied with this result, as I'm sure there must be something I'm missing... 🤔

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว +1

      If you're using Discord, you can bring the discussion (and files?) to my server. Find the link in my Twitter bio (@ TechArtAid). Maybe someone will have an idea

  • @momomadi2
    @momomadi2 3 ปีที่แล้ว +1

    nice coming back

  • @fnbs-l9o
    @fnbs-l9o 10 หลายเดือนก่อน

    Amazing really help my problem thanks !!! :)

  • @eternalslumber8580
    @eternalslumber8580 3 ปีที่แล้ว +1

    Great tutorial as always

  • @rodrigosoriano6464
    @rodrigosoriano6464 3 ปีที่แล้ว +1

    Super cool video, thanks a lot!

  • @myth0genesis
    @myth0genesis ปีที่แล้ว

    I didn't even know about the custom primitive data thing. Really handy optimization now that Geo Scripting is in beta!

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว +1

      Right, great for the PCG plugin too! (per-instance data, but the concept stays the same)

  • @omidmiresmaeili
    @omidmiresmaeili 9 หลายเดือนก่อน

    Thanks for the great tutorials. I was wondering, how do you measure such blueprints performance (as compared to a C++ approach)? On a related note, is there an equivalent C++ interface for working with custom primitive data and creating dynamic materials?

    • @TechArtAid
      @TechArtAid  9 หลายเดือนก่อน

      There is, yes. For measuring, Unreal Insights + see my UE4 graphics profiling videos
      Edit: ah, you've seen them :3

  • @kenalpha3
    @kenalpha3 2 ปีที่แล้ว

    This is cool. I was looking for a way to animate Materials of spawned pickups, without using Level sequencer, so I could put the animation in the BP, because I'd need to set Touch events for each pickup (thus I didnt want to reference exact actors in Level sequencer).
    Ultimately I didnt animate a Material (like fade in and out). But I setup my Master material to have 2 parameters: glow color and opacity, which change.
    So when the Player touches the pickup (fuel), if he is full (at 100), then I dont want to do the normal destroy actor event, to keep the pickup on the map for later.
    So I set 4 variables. Original opacity = 1. Changed opacity = 0.5. Original color and changed color.
    So when the player touches, if he's full, I use a branch, and the material on the pickup turns to 0.5 transparent and changes red, as tho the pickup is on time out (using his set Custom Primitive Data - Float = Opacity). Then after that I have a delay =1. Then I again set the Custom .. Data back to opacity 1 and original green color. And this transition seems to look good. And the player knows he can come back, touch it again to refuel (if he needs to).

    • @kenalpha3
      @kenalpha3 2 ปีที่แล้ว

      Wait I finished the vid now. If I want to animate, how do I get your example files?

    • @TechArtAid
      @TechArtAid  2 ปีที่แล้ว

      This tutorial is the only one that's not contained in the "Assets from YT tutorials" package. That's because I made it for the "Math Essentials" originally. If you want to buy Math anyway, get the variant with project files on techartaid.com/products But better reach me on Discord and I'll send you the scene - discord.gg/qhPdwV453B

  • @zapalniczkakaminski9990
    @zapalniczkakaminski9990 3 ปีที่แล้ว +1

    HE'S BACC

  • @hotsauce7124
    @hotsauce7124 ปีที่แล้ว

    Question: May I ask how I can use a material MATH node to offset a UV across an Atlas? Ultimately, I would like to use a Control Rig controller (set to integer) that would offset the UV across the atlas one UV tile at a time? When the Controller is moved along the X axis, the controller will be at an integer value of 0, 1, 2, 3,...24. The controller’s integer value would offset the UV one UV tile at a time across the texture atlas coordinates set in the material, the UV would pop across the atlas not slide across the atlas. Linking the UV position in an atlas to a Control Rig controller is on my mind. Thank you for this video, it is brilliant.

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว

      Yes, that's a real use case indeed! Use the SubUV node to shift a frame along an atlas. Or if you want to do it manually, for some reason, then multiply the coordinates by X frame count (integer, e.g. 24), floor or round it, then divide back (by 24).
      Search for "convert 1d coordinates to 2d" to learn the math for getting the Y row index (X2,Y1 from 27 in your example). It involved modulo aka fmod

  • @lilouhaefner3352
    @lilouhaefner3352 2 ปีที่แล้ว +1

    15:30 Can't you use bool parameters? Or do they not work with custom primitive data? That would make sense if it's an array of 32 floats where the padding would be in push constants.

    • @TechArtAid
      @TechArtAid  2 ปีที่แล้ว +1

      Thanks for pointing that out. Actually I forgot that UE has bool params :o At work, in our custom engine, I used to pack 32 booleans as bits into a single integer, then reinterpret_cast() it to float before sending to custom primitive data. HLSL has a similar function that changes float type to int type bit-wise (and vice versa)

    • @lilouhaefner3352
      @lilouhaefner3352 2 ปีที่แล้ว

      @@TechArtAid That's clever, reinterpreting a bitfield as a float to use it as primitive data. I'll probably use that now if you don't mind :D

  • @hotsauce7124
    @hotsauce7124 ปีที่แล้ว

    Request: can you please do a video on promoting an integer variable from a controller or bone? And plug the variable into two parameters in a material: U offsets and V Offsets? If a bone or controller translates along an X axis it outputs an integer variable. That integer variable will translate the U offset and V offset in a material texture atlas? I cannot seem to figure this out, may I ask for your help?

  • @MonsterJuiced
    @MonsterJuiced 3 ปีที่แล้ว +1

    Can you do this with textures rather than just basic colours? Say I have diffuse, roughness, metallic and normal, I'd like to be able to interactively change each one to another texture. Great work btw, this is extremely relevant to my current project :)

    • @TechArtAid
      @TechArtAid  3 ปีที่แล้ว +3

      Thx! It's possible to some extent, though in a non-optimal way (performance wise). Normally in GPU APIs like DX, OpenGL, you can't just "rewire" a texture dynamically without creating a new material instance (draw call). In theory, bindless resources allow that, but UE doesn't expose that to you. To work around it in UE, I'd create multiple texture parameters, then "choose" the one to be used. The choice can be implemented by multiplying unused textures' RGB outputs by 0, then adding all of them together. A vector parameter (custom prim data) then needs to be set like 1,0,0,0 if you want 1st texture, 0,1,0,0 if you need the 2nd one etc.

    • @MonsterJuiced
      @MonsterJuiced 3 ปีที่แล้ว

      @@TechArtAid This is great advice thank you! My project kind of depends on many individual materials to be interactive which means I need to be saving resources wherever possible really. I'll experiment with what you mentioned :)

  • @alhusseinali
    @alhusseinali 6 หลายเดือนก่อน

    Does it works with texture sample or just for only store Vector and Scalar values?

  • @laeioun
    @laeioun 2 ปีที่แล้ว +1

    I want to create several different meshes with different textures for the same character and somehow swap or blend between them dynamically depending on nearby meshes in the character's surroundings, like a chameleon. How would I do this?

    • @TechArtAid
      @TechArtAid  2 ปีที่แล้ว +1

      The answer demands at least a video ;] Let me add this to #next-stream-ideas discord.gg/jC9eHyUTBm

  • @vijayanandkankonkar7234
    @vijayanandkankonkar7234 3 ปีที่แล้ว +1

    Hi, great video,
    Can we have the source files of this scene? Thanks

  • @brunofragamoraes2363
    @brunofragamoraes2363 ปีที่แล้ว

    Hello there, awesome tutorial. To keep draw calls in check this is great, but what would be the difference of this and calling "Set (..) parameter value on materials" directly on the static mesh? I've tested here and no extra draw call were displayed on avarage or max. And again, great tutorial!

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว

      Glad you enjoyed it! Do you reuse materials on other meshes? I don't know this method, but I guess it does one of the two:
      1) change the value in the material instance, therefore changing it on every surface it's used on
      2) create a dynamic material instance on the fly, increasing draw count +1 in case of a reuse

  • @PrivacyEnt
    @PrivacyEnt ปีที่แล้ว

    Hey! when we use the set scalar parameter value on materials function, how do we tell it to change only the material element 2 for example? say I wanted to change roughness scalar value, but only of the windows, not the walls, how do i tell it to use material id 2 ? (because all my materials has the same name "roughness" for its roughness channel, and ideally i would like to keep it that way:DDD )

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว +1

      Tell me if I understood correctly:
      1. you want to pass parameters to a material function you made (e.g. ApplyDirtAndLeaks) in multiple materials
      2. you have windows and walls in the same mesh
      3. windows and walls have to use the same material slot?
      3a. if no, then it's easy - right click on the material and make a Material Instance (read or watch about them, as they're nicely documented)
      3b. if yes, you'll need to have some material ID mask. then run the function twice, with different parameters (passed through a FunctionInput node in the function). then mix the results using a Lerp node

    • @PrivacyEnt
      @PrivacyEnt ปีที่แล้ว

      @@TechArtAid Thanks for the reply! I think i kinda get what you mean, and its similar: I have windows and walls in the same mesh, with different material slots, slot 1 wall, slot 2 window.
      and in the blueprint, i want to change the roughness of window's material instance(which has a scalar called roughness)
      using "set scalar parameter value on materials" for the wall+window mesh, it changes roughness of the wall as well, since the wall material instance has also scalar named roughness :D
      so easy answer is: just rename the scalar parameter in one of them.
      But I was wondering whether you know of an alternate method without using dynamic instance materials. Because as far as I understand that costs extra in performance?

  • @mindped
    @mindped 7 หลายเดือนก่อน

    when i use this to change Custom primitive data as an editor tool.. it seems to change it, but the values remain the same when i select teh object... visually its different. How do i save the numberic values into the actor at the bottom right in the details tab? Im using CPD to reduce draw calls so basically almost everything in my level has custom primitive data on it. Also is their a benifit to using material parameter collections over simply just applying the settings per static mesh actor?

    • @TechArtAid
      @TechArtAid  7 หลายเดือนก่อน +1

      In Details, there's a Custom Primitive Data Default, or something like that

    • @mindped
      @mindped 7 หลายเดือนก่อน

      @@TechArtAid thx that worked

  • @dieblauebedrohung
    @dieblauebedrohung ปีที่แล้ว

    Is there a way to use Custom Primitive Data for actual textures or something along those lines?
    Like if I have 20 instances of the same object but wanna give them different textures (not just single colors), can I do that?

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว

      Yes, via shifting the coordinates on a UDIM (just add offset to UVs). See this vid: th-cam.com/video/-oFY5QWXKZY/w-d-xo.html

    • @dieblauebedrohung
      @dieblauebedrohung ปีที่แล้ว +1

      @@TechArtAid Okay, ngl, that's pretty amazing. It might not help my cause since I'm not the one making the models and they'd have to rename them probably, but that's super sick, I'll experiment with that.
      Thank you :D

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว

      Good luck :) udims are fun to explore

  • @kalimdorman
    @kalimdorman 3 ปีที่แล้ว +2

    :)

  • @speedwaylabsdev
    @speedwaylabsdev 2 ปีที่แล้ว

    Does this work with multiplayer?

    • @TechArtAid
      @TechArtAid  2 ปีที่แล้ว +1

      Hm I don't know if Custom Prim Data can be replicated automatically. But it should be very straightforward to sync it, through a variable that's replicated

  • @rodrigocezar3667
    @rodrigocezar3667 ปีที่แล้ว

    That's Unreal Engine 4, not 5, I wish I could fix dynamic material after migrating to ue5

    • @TechArtAid
      @TechArtAid  ปีที่แล้ว +1

      It works exactly the same in 5

  • @TechArtAid
    @TechArtAid  3 ปีที่แล้ว +2

    By the way - in the "If" node in material, do NOT connect A==B unless you need it! Leave it empty, otherwise it produces more instructions. My bad :D
    twitter.com/Deathreycg/status/1307984520294076416?s=19