Mask Modifier - Alireza's Art Blog

Polycount Sponsor
Offline / Send Message
Maximum-Dev Polycount Sponsor
Hello Polycounters,

I have recently received a lot of requests for tips, tutorials and tricks here in forums and on UE4 FB group regarding the work I do, some of which belong to the game I'm creating with some of my friends [Our Ghosts of War]. I considered creating a blog but for the sake of better exposure I decided to just create a thread here. Anytime I have something to share I'll be posting in this thread and I'll be honored to answer your questions (if any).

I'm currently putting together a post about my lighting approach. If you have any requests please let me know.

Thank you.


Replies

  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Hey everyone,

    There was a small discussion on UE4 FB group regarding using Albedo to create a Specular map. I think this deserves more clarification.

    The intensity multiplier on my rock specular in the picture I posted earlier was actually low, my apologies for that. But increasing it can produce results pretty close to what an actual cavity multiplied by 0.5 does. For us I'm only doing this to save on an extra cavity map. To be honest the Megascan Albedos aren't completely shadow free so running the albedo through a Power and Multiply and finally a Clamp with min 0 max 0.5 and a little tweaking can let you amplify those shadows and use them for Spec. Here's the Spec Buffer view: 



    If you multiply a cavity map by 0.5 you get almost similar results to what you're seeing above. It's not 100% the same when you compare it side by side on your screen close up. And not using a separate cavity map is a great memory saving by itself so this is what I decided to do for our game and other side projects.
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Tip 04 - What grass shapes work better?

    I have experimented with lots of grass meshes and lots of grass fields. One of the nicest ones for me (in terms of forms) is the one below. My goal was to create a low poly grass field that runs well and has some interesting height variations to it. So I made a lot of grass meshes and I'm gonna show the two winner meshes below.





    Above is the medium grass. It's a single plane instanced 6 times. The texture that I'm using on the mesh is actually very straight grass blades material from Megascans and I couldn't really find my desired texture on the  library so in order to make it look more like bent grass patches I've rotated the two instances on each end outwards. Doing this I realized the curve that's created on the top (as you're seeing in the front view) adds a ton to the look of the grass field when I'm looking at it in UE4. That curve makes it transit smoothly to the other small grass. The 3 other instanced planes are doing a great job making it look more 3D from perspectives other than front. Basically X grass as you see in the top view.

    This is the mesh for the small grass:



    I have been doing a lot of variations but in the end I went with this setup to have a more uniform distribution since this is actually small grass and is only there so when you look down you see some stuff going on around you, not dense at all. If you're wondering why the square shape, I'll cover that some time later. So the two grass meshes aside, I'm mostly relying on the grass material that's on the landscape surface. Here's me looking down:



    When looking at a large grass field all grass meshes get culled at some distance. I did endure a lot of pain in order to make the transition from grass meshes to landscape grass material less apparent when the meshes are culled. I'll cover this at a later day as well.

    Note: I'm in no way an expert in anything and in no position to try to lecture anyone. I'm sharing what I found to be the most helpful in my cases and if anything in this thread helps anyone, I'll be glad of it. :)

    Thanks for reading.
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Tip 05 - Grass is shinier on the other side and it needs to be taken care of!

    I looked around A LOT. Spent a lot of time trying to figure out a solution. This is just another flaw of the PBR in my opinion. We have translated the real world surface rules into game engines without having the power to have the same real world geometries with trillions of triangles to apply these rules to. Looking around I noticed the Cryengine community had the same problem but Crytek has already dealt with it. This slide gave me some clues.



    Here's a very very simple grass material:



    And this is how it looks like on the landscape surface:



    But as the sun starts to rotate, you start to have reflection problem. No where in the world a grassy ground looks like this:



    So I reconstructed a Specular map using the Albedo, as I have explained in Tip 02 to prevent 100% of the surface from reflecting light equally. This is how it looks like in the material editor:



    And this is how it looks like on the landscape, but it's still way off...



    To reduce the specular gain I went ahead and used the Fresnel node to mask out the area where the specular is gaining, and reduced the specular intensity for those areas from 1 to 0.33. This is how it looks like in the material editor:



    And finally, this is how it looks like on the landscape surface:



    But still, it does look off somehow. You notice in the middle the reflection is stronger. If we had grass meshes here, when they are culled it'd look too obvious that they are disappearing and breaks the immersion into bits. Next time I'll cover how I went around this issue.

    For demonstration I have used a grass material. But any material that's rough and has a lot of volumes to it in real life like grass does, it can greatly benefits from this method.

    Thank you for reading!
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Hi guys,

    With the release of 4.15 the LUT included in Tip 01 no longer gives correct results due to the tonemapper changes. I have created a new LUT that works correctly with 4.15 unclampes the whites. Left is with LUT, right is without.



    I realized using the Levels modifier gives more accurate results over Brightness modifier. You can grab the LUT  here.
  • Sajeet
    Offline / Send Message
    Sajeet polycounter lvl 2
    Thank you for these tips m8! :) Keep them coming. And thx for the LUT
  • Steppenwolf
    Offline / Send Message
    Steppenwolf polycounter lvl 9
    There are a few more tricks for the specular grass problem. You can use macro masks in the material for distance specular or roughness variation and you can use the composite texture feature to create roughness variation. https://docs.unrealengine.com/latest/INT/Engine/Content/Types/Textures/Composite/

  • KHM3dia
    Offline / Send Message
    KHM3dia polycounter lvl 3
    You mentioned the fact that placing the Roughness and Ao in the Normal map and changing it to masks. Would that cause any quality loss since the compression isnt set to normal? Although the blue channel doesnt get used, I suppose youre method should work fine. From my experience ive always packed Roughness, Height/Metallic, AO and possible Cavity in the Alpha and used parameters if i want to use certain channels but also use scalar multipliers to controls the strength. 
  • Wenceslaus
    Hello!
    Thanks a lot for all this, it is really valuable to me.

    Does the "AO multiplied on Abledo" means you multiply both into the colour input? I wonder if it could be done in Photoshop to save one operation (if that will have any effect).
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    KHM3dia said:
    You mentioned the fact that placing the Roughness and Ao in the Normal map and changing it to masks. Would that cause any quality loss since the compression isnt set to normal? Although the blue channel doesnt get used, I suppose youre method should work fine. From my experience ive always packed Roughness, Height/Metallic, AO and possible Cavity in the Alpha and used parameters if i want to use certain channels but also use scalar multipliers to controls the strength. 
    Yes there is a slight quality loss when setting the compression type to Masks, but as long as the surface isn't wet/glossy it's quite unnoticeable. You can channel pack your AO, Metallic, Roughness, Height into a single RGBA but usually materials do not need a Metallic map as they have nothing metallic in them, Roughness can be generated inside the material editor from an albedo, AO can be just baked on the Albedo instead of multiplying it on Albedo inside material editor, Cavity can be just ignored as AO can produce pretty close results, and you'll be left with only a heightmap, which can be put in Normal map blue channel. That's my approach mostly. And please keep in mind we're talking about organic materials such as Ground, Wood, etc. and I don't recommend this for things such as Weapons, Characters and such other assets.

    To reconstruct normal map's blue channel:


  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Hello!
    Thanks a lot for all this, it is really valuable to me.

    Does the "AO multiplied on Abledo" means you multiply both into the colour input? I wonder if it could be done in Photoshop to save one operation (if that will have any effect).
    Yes. You can also multiply the AO on Albedo inside Photoshop, then you will need to pull the shadows from from Albedo and amplify them a bit in order to multiply it by 0.5 for specular, it get's a little dirty but it works. I've explained here: http://polycount.com/discussion/comment/2524408/#Comment_2524408
    But to answer your question more clearly, doing a multiply inside material editor doesn't hit your performance.
  • Ubuska
    Offline / Send Message
    Ubuska polycounter lvl 3
    Thanks for your tips! Saved some tips for future use.
  • Wenceslaus
    Thank you for the answer!
    I now have a little issue with the LUT_2 file you have posted... LUT_1 works still realtively OK.


    *edit: Silly me, I've just forgot to specify it is ColorLookupTable in the texture group in the texture details-
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Tip 07 - Sense of scale.

    Hello good people of polycount.

    I was working on a very small thing, mainly for learning purpose.
    Usually when working on a landscape the one big issue is having no correct sense of scale. When you're doing level design it's sometimes very hard to know how everything feels from a player perspective, how big is this rock? how long is that path? how high is that hill? how large is that field? These are all sort of questions that I'm always dealing with.

    When doing level design, what I've been always doing was to place the mannequin mesh here and there, look at it to get a sense of how big everything is. But that's actually not very helpful. The moment the mannequin isn't placed right next to what you're looking at, you lose the sense of scale. And on top of that, I got tired of placing mannequins here and there all the time.

    For instance look at the scene below, the rocks look nice, but there's no way you'd know how big they are. And knowing the scales is actually more important than making it look good.



    So what I came up with was to create a very small and simple grid function that tiles a grid on the landscape in world space, the easy way.

    Here's the function:



    And here's how it's setup in the landscape material. It get's all the inputs, with a BreakMaterialAttributes all outputs are broken and fed into the final input pins. Nothing complex.



    A few parameters are exposed to material instance.

    Opacity: Controls the grid opacity.
    Specular: Preferably set to 0.
    Roughness: Preferably set to 1.
    Size: How much the grid is tiled.



    I'm using a size of 1200 as you see. I know that makes the red squares as big to fit three sleeping dudes. (Outlined by blue).
    And just knowing each red square can fit 3 sleeping dudes, I'm now instantly able to have a correct sense of scale everywhere without needing to place a mannequin or anything else, simply by changing the Grid - Opacity from 0 to 1.

    Check out the squares I've outlined with green, now you know precisely how big the rocks are.



    If you find this useful, you can download the function from here and put it in your content folder.
  • stilobique
    Offline / Send Message
    stilobique polycounter lvl 5
    Yeah, thanks to share your function ! You can add more information and description to add your function on your palette panel.




  • Ootrick
    Offline / Send Message
    Ootrick polycounter lvl 4
    Gorgeous dude! love the scale idea... well played that would be super useful: Put it on the Unreal Marketplace! .I'd actually love to know what kind of lighting procedures you use, especially the desert scene and how you balance things like exposure and indirect light intensity, you seem to have a very keen eye for lighting too.  Subbed! 
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    stilobique, Correct. Makes life easier. :)

    Ootrick, Thanks. For lighting after 4.15 I'm using Movable directional and Skylight + Cubemap loaded in PPV. LPVs enabled too. I have the same setup here and there, only values and cubemaps differ from project to project. My other microphone was busted, got a new one today and planning to do lots of tutorials from now. =D
  • macoll
  • Xendance
    Offline / Send Message
    Xendance polycounter lvl 7
    I'd appreciate if you posted breakdowns of the trees themselves. How the leafs were made, how the branches are structured, how did you bake the billboard and so on.
  • r4ptur3
    Offline / Send Message
    r4ptur3 polycounter lvl 9
    fantastic breakdowns!  thank you so much!
  • Martoon
    Offline / Send Message
    Martoon triangle
    Thanks for the helpful breakdowns and tips! Extremely helpful. :)
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Hi all,

    Small article published here thought you might find it useful.
    https://80.lv/articles/rendering-scanned-vegetation-in-real-time/
    The big redwood forest breakdown is being worked on.

    Good wishes, in particular.
    ~Ali
  • homart
    Online / Send Message
    homart polycounter lvl 2
    what's the performance cost of this?! Thanks for sharing the love ! ;)
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    homart said:
    what's the performance cost of this?! Thanks for sharing the love ! ;)
    Once used in a material it adds:

    Base pass shader with only dynamic lighting: 27 instructions
    Vertex shader: 1 instruction
    Texture samplers: 1

    So it's quite cheap.
    Glad you find it useful :)
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Just came across the values to recreate UE4's old tonemapper curve using Filmic Tonemapper. This can be useful for those who want to properly lower the Filmic Tonemapper's effect and not completely disable it. You can roll the values back slightly towards these values of the old curve.

    Old Tonemapper Curves:

    Slope = 0.98;
    Toe = 0.3;
    Shoulder = 0.22;
    BlackClip = 0;
    WhiteClip = 0.025;

    Source
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Tip 09 - Macro Normal variation.

    Again this is about large surfaces such as landscape. Variation in color makes the surfaces look nice up to a certain distance. But looking at a large surface from far away, that color variation alone isn't enough and needs to be coupled with macro normal variation to break up the lighting on the surface. Now this isn't anything complex or fancy, just a very simple function that can be helpful at times when working with landscapes or other type of vast surfaces.






    You can download the function from here.
  • StefanA
    Offline / Send Message
    StefanA polycounter lvl 6
    Thanks so much for sharing your assets, I'm loving each update. I'm having an issue importing your latest .uasset files however, they don't seem to appear within my project (even a new blank project). Previous u.assets have worked fine though... Does the GlobalNormalVariation.uasset require a specific version of UE4?
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    StefanA said:
    Thanks so much for sharing your assets, I'm loving each update. I'm having an issue importing your latest .uasset files however, they don't seem to appear within my project (even a new blank project). Previous u.assets have worked fine though... Does the GlobalNormalVariation.uasset require a specific version of UE4?
    I'm on 4.16.2 at the moment. In case you're using an older version that might explain it. For some reason UE4 does not have backwards compatibility. And I'm glad you find these useful. :)
  • Maximum-Dev
    Offline / Send Message
    Maximum-Dev Polycount Sponsor
    Tip 10 - Mask Modifier.

    It's been a while I've been building a whole library of modular functions that I can plug and play in every material. My initial goal was to save a bunch of time every time I move to work on a new project and I feel like I've achieved it. Once starting a new project, all I'd need to do is to copy my functions library over and start placing them in my materials where needed, cutting out the need to re-do the same setups over and over again in different projects/materials. I hope these will help you save some time too. :)



    You can of course add any other type of control inside the function.
    Download the function from here.
  • FishMan
    Offline / Send Message
    FishMan polycounter lvl 5
    Hey, thanks for the work you're doing and all the usefull stuff.
    Also do you know that you can change the inputs sort priority and thus make their order more familiar, like: red, green, blue instead of green, blue, red?

  • PixelGoat
    Offline / Send Message
    PixelGoat polycounter lvl 10
    Great tips in here! :) 
Sign In or Register to comment.