Home Unreal Engine

[UE4] Z-Axis Oriented Material Issues

polycounter lvl 12
Offline / Send Message
Will Faucher polycounter lvl 12
Hi,
So I am working on a moss shader for a project I'm working on.
The purpose is that have the moss show up on the Z-Axis in world-space, so that when I rotate my mesh, the moss only appears on the very top of the mesh. The problem I am having is adjusting the falloff.

The following screenshot shows the current falloff that I am able to set up in the engine. As you can see, the blend goes from top to middle in a perfect gradient.
OquaehQ.jpg


That results in the shittiness that is this:
idhbruK.jpg

Because my rocks are at a slight angle, they show up as completely covered in moss. I need to find a way to tighten that falloff, to something similar as the following screenshot. I want the moss to show up only at the very tip of the top of the mesh.
IWduffW.jpg

Ideally, I'm after a result similar to this paintover I did:
SS1WkaJ.jpg

How do you think I could go about doing something like that?

Replies

  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Use a larger value in the constant3. So like 4 or more instead of the 1. Or simply multiply the constant3 with a large number. Or maybe you can use the power expression somehow.
  • Khaja
    you could recreate the same technique from UDK that allows for parameters for falloff sharpness, angle and coverage. This is in UE4 but uses a UDK technique (that i sadly can't find good non-404'd resources for.

    UpvectorManual_zpsbceff71e.jpg

    That should help you. Need any extras just ask. (it's controlling an Alpha in a lerp as normal)
  • nfrrtycmplx
    Offline / Send Message
    nfrrtycmplx polycounter lvl 18
    You should dot the up vector against the Pixel Normal WS.

    as a post effect you could do the same against the screen space world normal.

    http://www.polycount.com/forum/attachment.php?attachmentid=18300&stc=1&d=1405148878

    The node is PixelNormalWS

    Dot that against your up vector

    Then to tighten the mask:

    Add 1 to the result and divide by 2 to make sure you don't have any negative values. Then apply a power of X - X being the desired sharpness.

    Clamp the result to range of 0 - 1. this will avoid artifacts when using it as a mask.




    http://www.polycount.com/forum/attachment.php?attachmentid=18301&stc=1&d=1405148878

    Then to sharpen transition from white to black:

    Then multiply by your desired sharpness and clamp that result.

    Note: In this example you could use only the one clamp and the result would be the same.


    I don't recommend using the UpVector against itself transformed from tangent to world space, as the result is the same as if you were to dot against the vertex normal WS. This will result in a "faceted" look in most cases.

    http://www.polycount.com/forum/attachment.php?attachmentid=18302&stc=1&d=1405148878
  • Khaja
    nfrrtycmplx: thats a nice way of doing it! cheers for sharing!
  • Will Faucher
    Offline / Send Message
    Will Faucher polycounter lvl 12
    I love you all so much. This is exactly what I needed! Thank you!
  • JohnHandyArt
    Hey, love this shader.
    Im using it to set up some moss for the rocks in my scene.

    Im having a little trouble using the mask to "Lerp" between 2 normal maps.
    It works fine using it for the roughness and Base Colour.

    I think its because im using the PixelNormalWS node, I have looked around but cant figure out why its throwing up an error.

    RockMask_zpsd4d9dc90.jpg~original

    Above: This is the set up I have for the mask

    RockLerpBase_zpsa005bd81.jpg~original

    Above: Showing the "Lerp" between the base colours working

    RockMaskNormal_zps68275aec.jpg~original

    Above: showing the error that pops when I hook up the mask to the lerp-alpha (the pixelNormalWS is the smae node that is connected to the start of the mask)



    If anyone can spot the mistake I am making it would be awesome if you could point it out.

    Thanks!
    John Handy Art
  • nfrrtycmplx
    Offline / Send Message
    nfrrtycmplx polycounter lvl 18
    Odds are good that you're doing arithmetic between a float 4 and a float 3 somewhere? Without the output from the log and a complete graph it's impossible to see from this image what the error is.

    On an unrelated note, why are you multiplying your green channel by -1 in the normal map 1? You can do that in the texture itself and save an instruction or 2. It also looks like you're trying to add detail normal to your surface, which should be achieved through the use of a blend angle corrected normal node (don't have unreal open at the moment to get the exact name of the node, but in the context sensitive menu simply type "Correc" and it will pop up. Hope that helps.
Sign In or Register to comment.