Announcement

Collapse
No announcement yet.

How to get a gradient around intersecting meshes.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    How to get a gradient around intersecting meshes.

    Hello! For my artstyle, I really like having darkened areas around where different objects meet, E.G:
    Click image for larger version  Name:	20200129-18_32_46Tribesmen--Unreal-Editor.jpg Views:	0 Size:	260.2 KB ID:	1716470
    I add shadows/grime where the metal meets the wood. Similar to ambient occlusion, but way more pronounced.

    However, I have gotten to the point where some of my assets are for modular use, for instance placing a torch on a wall.
    This means I cannot pre-paint this effect, as their placement isn't pre-planned.

    So I am trying to see if I can figure out a way to darken the area around where I place objects dynamically.

    I do not want depthfade, as they are depth-based and will show the objects behind what I'm trying to shade.
    I seem to remember have been able to do something similar when experimenting with a water shader using distance fields. But I haven't quite figured out how to use them this time, and are they resource expensive? Is perhaps a blueprint object with a decal better?
    Last edited by Graylord; 02-03-2020, 06:51 AM.

    #2
    blueprint decal might be better performance wise.

    A few other ways:
    Material only: You check Distance between the wall and the material - in absolute world position. - object position is a node, for the wall position you'd have to pass to the object via vector parameter - or simply create material instances and instance them for each set of assets based on the wall location.

    BP to Material.
    The BP does the math, the Material implements the shader based on the math.
    In BP you can expose a couple variables that you can then select from within the level - say actor static mesh as type (or similar, it's an actual entry if you type static mesh, and it's whatever a static mesh becomes when dragged into the level. A wall, is usually this type).
    Do the calculations with BP on the Begin Play node (lower performance impact). and pass the values required to a dynamic material instance.

    The other material only techniques would be based on transparency - you don't want to do that for non transparent objects. it's way too expensive performance wise.

    And the way you were talking about seems more like a Post Process effect.
    I suppose you could always go that route too

    Or
    https://docs.unrealengine.com/en-US/...nearestsurface

    But mesh distance fields weren't working last time I tried it.
    Last edited by MostHost LA; 02-03-2020, 07:17 AM.

    Comment


      #3
      I want just to add to what MostHost LA have already suggested. You can use the AO pass inside a postprocess material and use custom stencil of the barrels to mask out the AO effect to be only on the barrels.

      You can develop more the math after the AO for more finer control on look. In terms of performance I am a bit unsure how big is the impact compared to decals.

      Check screenshot below, good luck.

      Click image for larger version  Name:	LocalizedAO_01.JPG Views:	0 Size:	249.6 KB ID:	1716570
      Last edited by NasteX; 02-03-2020, 12:15 PM.

      Comment


        #4
        Fantastic suggestions from both of you, thanks! I'll definitely get something going with this.

        I also got distance fields working now, but found landscape distance field extremely strong and not usable in combination with distance fields from static meshes. But it gave me some ideas of how to use it as a mask for other purposes.

        Comment

        Working...
        X