How to Create Masks With the Custom Stencil Buffer | Tips & Tricks | Unreal Engine

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ส.ค. 2020
  • Masking enables you to alter specific parts of your final scene without affecting everything else in it. There are several options in Unreal Engine to perform real-time masking.
    In this episode of Unreal Tips & Tricks, we focus on using the Custom Stencil Buffer in a Post Process Material which allows us to alter how multiple objects are rendered on the screen. Thanks to the Custom Stencil Buffer, each object can be easily set up to have a completely different rendering style.
    For additional help, please see the documentation: docs.unrealengine.com/Engine/...
  • เกม

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

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

    This really helps!! Finally, there is a tutorial with clear explanation about post processing!!

  • @alienrenders
    @alienrenders 9 หลายเดือนก่อน +6

    To make this obey depth buffer, add two more scene texture nodes. Select SceneDepth and CustomDepth. On each, add a Mask node (leave R checked, uncheck the rest). Link CustomDepth (mask) to the top of subtract node. Link SceneDepth (mask) to the bottom. Use a Saturate node on the result of subtract. Then feed that into a 1-x node. Then multiply this to what you're using for the alpha of your last LERP node and use the result as your new alpha.
    Make sure your actor has the checkbox enabled to write to the Custom Depth buffer.

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

    Super useful! Ive been looking at how to do this for ages, this is quite a simple approach.

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

    one of the best and to the point tutorials/examples. thank you for the reference content. have had to come back to this video several times

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

    8:24 - There is one major issue with this tutorial:
    LERP Alpha in UE4 is not clamped. This means it can go beyond the range of [0,1]. If you feed an alpha of 2 there, it won't stop at value B, but instead will interpolate further. Which will Oversaturate the colors.
    Example:
    A = 0, B = 100, Alpha = 2 -> Output will be 200.
    To clamp value in [0,1] range use SATURATE node.

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

      Very nice! Read your comment before finishing the vid, just duplicated a spare box and saw the color change as soon as I upped the stencil depth number. Tweaked it as ya said, boom! Perfect!

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

    Finally, I've been searching for an answer to this question since literally 2015. THANK YOU!

  • @DavidAllenFarrell
    @DavidAllenFarrell 2 หลายเดือนก่อน

    You were born to do this kind of work.
    Thank you.

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

    Thank you! It took some time to figure some stuff out muself, but this is really helpful!

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

    dude, amazing tutorial! thx a lot!

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

    Keep making these shorter and consice tutorials, we don't need the drawn out intros and podcast style tutorials are way too long.

  • @user-ow6fn1lj2f
    @user-ow6fn1lj2f 2 ปีที่แล้ว

    I can understand so easily! thanks to this video

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

    This was really useful, thank you

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

    we need more video like this

  • @user-mf2bf1kk1q
    @user-mf2bf1kk1q 4 หลายเดือนก่อน

    Great tutorial: to the point! Thanks

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

    This is amazing explanation !!!!!

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

    Great Explanation, Thanks A lot

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

    What a great tutorial

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

    Hey thanks! You saved my life!

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

    That´s what I call "TEACHING"! Thanks!

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

    Good stuff.

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

    Thanks for the tutorial, this is approaching pretty close what I need to accomplish, but I'm wondering if there is a way to create stencil passes PER track/element- or individual meshes of an object? I'm working with alembic geometry caches of character animation and would like to be able to isolate certain parts of a render (like the eyes for example) independent from the rest of the object. Is there a way to do this without having to import every single character element separately? Ideally it would be great if you could assign custom stencils according shader Id's.

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

    anyone know if its possible to enable and use Custom Stencil pass on Decals? it works with meshes but it seems not to work with decals

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

    To make it more useful, the Custom Stencil really needs to be made available for Opaque materials in the pixel shader. It's already possible with engine modifications, but it's a nasty hack to do so.

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

    So the full color on certain objects is working... but whenever that object is placed behind something, whatever is in front of it gets full color based on the shape behind it. how do you fix this??

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

    God damn! Texturing is a mindblowing brain! You have to be alien to understand it lol.

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

    Any thoughts on being able to identify if an actor is currently showing its custom buffer/stencil? I'm looking to trigger events only when an object displays its stencil.

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

    6:57 🖤 from DEMONS WIZARDS

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

    I am trying to use this technique on my ocean, so that it doesn't have a comic outline like the rest of my game.. I'm soooo close... but having an issue on where to hook it up on my material. Must... Study... More... Materials! :D

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

    How could I render that mask as an alpha channel instead of a color? I want to use this technique to create an occlusion object in Virtual Production, which is running realtime, so Luma Matte usage isn't possible, I really need the mask to render as an alpha channel. How would I go about creating that?

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

    Is there a way this can be applied to lights? For example, an IR light/laser

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

    Awesome feature for the most part. But it doesn't seem to work with sprites. :(

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

    I think I can speak for most of us saying... we've heard enough about "making your own masks".
    Can we give it a rest already?
    Oh wait, what?

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

      Lol I had a hard time getting it 😭😂

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

    Greetings_!!
    Thank you for the helpful tutorial_!!
    I have sprites instead of regular objects on my stage.
    These sprites are markers that I can colorize.
    The problem is that the color of the material is not accurate due to the lighting in the scene.
    In the editor, I can turn off the light by applying the unlit mode, but after building the project, this mode is not available!
    I know that this effect can be repeated by inserting into (post-process material) your post-process material with a diffuse map.
    After this action, my sprites on the stage become transparent, how can I avoid this or am I doing something wrong_?!
    Thank you in advance_!!

  • @ty1978
    @ty1978 5 หลายเดือนก่อน

    How would you go about using this method on decals? My scene is black and white using a desaturate in the PP Mat but I need for the decal (blood etc) to still be red when I shine my flashlight on them. I set up a Decal BP to test but the decal has no custom depth, any ideas? Thank you!

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

    Lets say I want to render an object that is behind a wall infront of a wall as if the wall wasn't there, how could I do that?

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

    Make "add AOV channel", or custom buffer, and it will simplify everything.... instead of that duct taping style. *Make simple things simple.*

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

      This would make it a universal change to the object, where the current implementation is selective use. In this example, it's to a specific post process material. Keeping things modular enables more use case scenarios at the cost of ease of use. Epic is pretty good about not over simplifying features that would put them in a small box.
      Edit:spelling

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

      That said, tools to create "render layers" would be fantastic! These overrides would be specific to rendering and would not be expected to function properly in realtime.

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

    wow

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

    Is there a way to do it inverted, where the post processing only affects the object, and not the reset of the environment?

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

      what do you mean? just affect the result of the stencil buffer to modify the affected range, you are supposed to do it in material

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

      This is an old comment, but the way you can isolate your object is by putting a 1- node before the multiply in the shader, it'll invert the mask in there.
      If that's what you mean.

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

    Whats the difference between this and using the default channel system when we are rendering out custom passes? Does this take into account the depth of field?

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

    How do I prevent the mask from being visible even if the masked object is occluded by something else?

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

      did you find a solution ?

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

      @@joelwynd9233 Did you? Lmao

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

      @@Urammar you need to assign a stencil mask to everything else in the scene as well. Object being masked = stencil 001. Everything else in the scene = stencil 002 . This worked for me

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

      @@joelwynd9233 thank you, but I've actually found a more robust solution! Compare the stencil with a custom depth/scene depth comparison. It's probably not as performant though, but it catches all the edge cases

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

    how to hide actors with post process and custom stencil?

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

    Hmm, this doesn't seem to be working on Blueprint object. Well not in UE5. Haven't tried older versions

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

      this works fine for objects inside blueprints in UE5. Are you trying to put the post process volume in a blueprint? Because you can't do that.

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

    Thanks, but my head hurts trying to comprehend the later part of the videos...

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

    Why the objects have no jitter? I've been working this for two weeks...

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

      Could I get the resource in this case?

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

      Try changing the processing in your post process mat setting to be before/after tonemap

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

    Can you do a live stream or a video explaining ai with Fortnite henchman or bots

  • @user-yo4jd6bt1y
    @user-yo4jd6bt1y 3 ปีที่แล้ว

    Pes2022

  • @logandoejogando...7532
    @logandoejogando...7532 3 ปีที่แล้ว

    WHAT 100% OFF MEANS IN THE UNREAL ENGINE STORE