Home Unreal Engine

[FOLIAGE & UE4] ~ Grass, full 3D strands to cards LOD transition, is it possible?

1
triangle
Offline / Send Message
Steamy_Steve triangle
I'm still banging my head on the foliage topic to find my own workflows/methods/techniques.
Trees may be dimmed a success.
Now on to grass (again, actually).

I've already tried, and I keep trying, to achieve a full-3D to cards transition to improve performance, but it seems it is not possible to make cards match the look of full 3D grass.

I'm open to alternatives, like full 3D but with a lower polycount. Which is what I achieved with UE4's built-in automatic LOD generator.
The result is impeccable, to my eyes, but I wonder if the polycount is acceptable at all. On my 980Ti, the framerate in the reduced view pane fluctuates between ~100 and ~110 and I wonder: is this ok?

I've taken some screenshots of the same landscape in different modes, but I cant interpret what I see. Help, please....?



The same landscape screenshot'd in "lit", "lod levels", "shader complexity" and "shader complexity + quad overdraw".
Obviously, the shader complexity is nearly non-existent, since every single strand is a 3D mesh without transparencies.
Quad overdraw is not a thing for the same reason.
The framerate, however, is quite unstable and I dont know how to interpret it.

Is it ok to have such an amount of triangles, for a grass-covered terrain?
I've tried using cards, but, let alone the awful transition, something looks terribly wrong with lighting. And I dont understand why.....


To answer some of the most probable questions:
.- yes, those are crossed cards
-. yes, they have normal maps from a projection of the 3D strands onto a plane
.- yes, I've used the 2SidedSign node to invert normals on back faces

I'll keep trying while waiting for advice.

Thank you.

Replies

  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    So first and foremost the question of polycount being to high can't be answered since you have not posted the polycount of the scene in any of your sceenshots.

    So why exactly do you want to go from full 3d blades to cards? Is there an issue with using cards outright? The transition would be much less noticeable IMO. Likewise can you post some images of how your grass meshes look? It may be there is not enough variation in rotation of card objects or they are at too steep of an angle when intersecting.

    As far as the different modes go for the LOD vis it's white= LOD 1 red= LOD2  Green=LOD3.


    As far as the overdraw goes can you post a screen of the grass in overdraw viewmode? Shader complexity+quads is just drawing the wireframe over the meshes.
    There are a plethora of tricks that can be used to make grass look better. You say you've used a two sign node but have you edited your normals inside your modeling software to skew the normals? It achieves better lighting and a softer look to the meshes. Also are your LOD's also Mipping down your alpha textures? You should be able to use a high shader for the second LOD with the last and final one using the same mesh with a lighter shader.

    Right now the grass looks very blocky so I'm thinking a normal edit would fix that. As well as adjusting your alpha to not mip down on the second LOD
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @zachagreg
    I know how the LOD colour coding works, sorry for giving you the impression that was a mystery to me too.
    Here's a screenshot with just quad overdraw on (full 3D grass blades)....


    I've watched a number of tutorials on grass and none ever mentioned "alpha mipping" or "normal skewing".
    Anyway, just for the sake of completeness, here's my LOD1 and 2 normal map (they use the same shader, which is very simple)....


    That normal map is the result of a projection of these strands on a plane....


    Then I cut the plane around the projection to get LOD 1 (960 tris) and 2 (378 tris)....



    Each "patch of grass" covers a round area of 1 meter in radius (2 meters diameter).
    I *did* manipulate the plane's vertex normals to point straight upwards, btw.

    These are LOD 1 and 2 from top view....


    I'm very grateful for your help, dont give up! ^.^
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Ah I see a big issue right off, the aliasing around your planes is very apparent and I suspect only becomes more apparent as you group more and more of them together. Where are you baking down your transparency, color, and normals? That one step will go a long way in cleaning those up.

    Next up I don't think those planes need so much lateral definition for the most part.  They kind of wave back and forth right? I wouldn't worry about that for right now as there are other things to test, but thought for the future.

    As for the normal skewing the manipulation of the normal to point upwards is what I meant. There are some cases though that are worth a shot after the aliasing is sorted out where the normals being oriented differently can produce a beneficial effect. Also try turning off your Tangent Space Normals in your material details to sort out some lighting problems you may be having. Try those first and then we can investigate into changing the alpha mipping and differences in the way the normals are manipulated.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    The Alpha map and BaseColor were baked with xNormal, while normal and AO in Substance Painter.
    This is because SP doesnt feature options for alpha and high-poly textures baking.



    Yes, I made the planes wavy in an attempt to emulate what I've seen on a couple of tutorials and I've been told by other people during my previous 6 attempts at making good looking grass.
    I guess I could furtherly simplify the test by just cutting a square around the grass alpha, without minding eccessive transparent areas too much.

    If with "aliasing" you refer to how it looks in Blender, I think that's just a thing of the 3D view, when it's rendered through Cycles it looks sharp and without any white-ish edge....


    What do you mean with "turning off your Tangent Space Normals in your material details"?
    You mean unplugging the normal map from the shader in UE4?
    Or just baking the normal map in object space?


    EDIT (2019.03.09 01.50pm): this is how it looks when I use flat cards only for LOD0 (no LOD 1 and 2)...


    It *obviously* yields a nearly steady 120fps, and despite the abominable quad overdraw....


    I'm starting to question the absolute truth that quad overdraw is a performance killer.... ^^'
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Have you tried out Blender's Textools by renderhjs? Brilliant baking tools inside blender so. Removing the lateral waves did seem to help a lot, go ahead and throw on LOD 1 and 2 so we can see if there is still some harsh transitioning. and that way see if the alpha map mipping is causing weirdness in the other lodsI would also recommend slightly tilting those cards down to make the intersecting angles less apparent.

    For the tangent space normals I am referring to this checkbox in the UE4 material editor.


    It looks like the normal you baked is in object space so you don't want that turned on because it's basically telling the material to accept tangent space instead of your object/world space normal. 

    As far as the quad overdraw goes it is bad and it is a performance killer but you need to think of it like Mercury poisoning, is that it will build up and build up as you use it and tank performance. It's not like a dagger that will just kill you as soon as it happens.

  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    This is what it looks like with "Tangent Space Normal" off....


    I *did* set SP to bake tangent space normals, though, why would I not? And what made you think I didnt?
    At the moment it's no use to make LODs other than 0, it wouldnt make any difference since the current cards are just clean rectangles (hence the unsightly amount of quad overdraw). Right?

    Anyway, this is the same cards, but tilted and with a brighter subsurface colour (and tangent space back on, of course)...


  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Ah okay my mistake this image:


    The color spectrum looks more akin to an object space normal map then a tangent space one.

    Anyway, much of the noticeable intersecting is gone for now which is good. The main reason I would say to include LODs is that you can still decrease poly amount per cluster which would in theory reduce quad overdraw. As you have less geometry behind to cause the overdraw. Just decrease the amount of planes around half going from LOD 0 to LOD 1 then for LOD 1 to LOD 2 keep the same amount of planes and we can get into whether or not the mipmapping on your alpha is causing a harsh transition. Make sure your for right now that all of your LODs are using the same material.

    At this point I would like to address what you do not like about the current result as well so I know what exactly you're trying to get, other than the smooth transition between LODs that is. What do you like too?

  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    Set LOD 1 and 2 to half the triangles (from 60 to 30 per patch), which did improve the quad overdraw situation (slightly), but it's not that relevant at the moment: this is just a test, I hurried and intentionally overlooked the shape of the cards to focus on your instructions and make the whole testing process much faster.
    I've also lowered all of the quality settings to "Lowest", for LOD 1 and 2, which did not impact the visual quality at all...apparently.
    This is how it looks with LODs....



    I can't really hope to get something *this* good at a first attempt.....
    [ https://80.lv/articles/tutorial-grass-creation-for-games/ ]


    But I could settle for something like this (although with normal maps projected from a high-poly mesh, that's not negotiable)....
    https://www.youtube.com/watch?v=q7IZStYmImY

    See how you cant really tell where the cards start or end? Especially in the first one....although, let's be honest, without some nice trick, that grass will look flat as hell, from the wrong angle!!
    There's something I'm missing, here, some step or gimmick that I just cant grasp.

    The technical part is sound, I believe, then what am I doing wrong?
    And WHY aint the first artist minding quad overdraw at all?! It's like he got a "get out of jail free" Monopoly card for overdraw!!
    Aaaaaaaargh!!!!! >O<

  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Hey if that top one is what you want we can go for it. No problem. Alright so first couple of things that you need to go through and do.
    1. Notice the differences between your meshes and Tim's, I know a lot of it had been simplified for the sake of getting the shading right in engine. But, notice how many blades of grass per card he uses and how dense each card is. When you compare them also look at the average width of each card he uses, the longer a straight edge is the more it will be noticed. Don't worry about subdivisions within the cards, those can be added later focus first on the cards dimensions and the density of grass.

    2. Once you have picked out the differences go through and make those grass blades, make as many as Tim did, it's a good amount of variation IMO. Spend some time on this make them nice especially focusing on silhouette and those seed pod/weedy looking ones. If you get stuck in that process post it. Don't bull rush through it let the problem evolve and be solved.

    3. All the baking can be done in substance painter including the opacity mask and I can show you how once you've gotten those grass blades done and laid out.

    The thing you are missing and what I think is the most frustrating is that there is no small trick. Making grass and foliage in game engines look really fucking good is just about the best example of Gestalt I can think of.


    ge·stalt
    /ɡəˈSHtält/
    noun
    Psychology
    noun: gestalt; plural noun: gestalts
    1. an organized whole that is perceived as more than the sum of its parts.
    This is what grass is in nature and this is what grass is in games. It is the combination of all aspects of its creation that makes it good. We got the weird technical things out of the way at this point now comes the time to make that highpoly you want and make it really fucking good. :)

    If it helps go pull up some grass around your neighborhood bring it back to your place and sit it down next to you on some printer paper. Recreate it in Blender. It's not what you're doing wrong, I wouldn't look at it like that. It's what you've yet to do.

    As far as the quad overdraw from Tim, I'm sure it exists it's just that when you don't draw attention to it it doesn't get mentioned. When you present evidence of a problem by saying man this overdraw sucks and you focus on that, that is the problem now and not, "How do I get realistic looking grass?"

  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    This is better, but the con is that the quad overdraw skyrocketed....




    Yes, I did cut the plane to minimize overdraw.
    Yes, I did set 2 LODs.

    It's a circular patch of grass that covers about 1 meter in diameter and reaches about 35cm in height...


    How may I improve it?
    More strands per plane and less planes?
    More triangles to cut closer to the alpha? (wouldnt work well, with this amount of blank space, I'm afraid)

    I went with the grass density shown in the lvl80 tut, but I guess it's not applicable to a large field of lush grass....?


    EDIT (2019.03.10 4.22pm): I've tried making a denser bunch to limit the overdraw and the amount of planes needed, but it seems I'm back to the initial problem, which is how it looks....


    Performance has improved drastically, though....obviously....



    I got an idea on how to get both, performance and good looks....but if you have an ace up your sleeve, pull it out, I'm starting to get kinda frustrated.... -.-
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Blades per plane is looking good don't change that. Let me see your wire frame for the planes as well as the bundle of grass so that I can comment on those as well. One shaded shot and one with wire frame always helps just a heads up. The density is applicable it just we haven't done everything we need to yet for a large field. One step at a time my man. There is some tech stuff we need to do later on once you nail down some things.

    So quad overdraw  is looking better in the last one so we will do a couple of things now and it comes down to variation and balancing performance and looks. This is making games in general its a balancing act and it can be infuriating at times so you're not alone in that.

    So first thing I want to recommend is go and locate whatever texture is responsible for your alpha on the cards and just turn off mipmapping for now.  Just find the texture, double click it and change the Mip Gen Settings to NoMipmaps. Just for now, we can revisit that later for performance.


    So for this grouping I'd recommend moving around the way the planes are oriented for right now, keep the same amount just try to get most of the outer most planes off the grid in the sense like these ones:


    Just takes some fine-tuning and trial and error here is a good base to start with though for shape.
    Try to mimic that kind radial layout that is there.

    What's making it look bad right now is too much uniformity. There no variation make at least one really tall bunching that is more tall than it is wide, maybe a quarter meter in diameter and make two smaller bunches of grass one that is half height and half diameter and one that is quarter height and quarter diameter.

    For the tall ones I highly recommend adding in some plant variation as well.
    Image result for wild grass field
    Choose 1 or 2 of any of these weedy things to recreate in your tall bunch. These can all be on the same plane much the same way Tim did his. Maybe add like small flowers to your small bunch to create color variation.




  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Hi. The foliage system in Unreal doesn't support different lightmap uvs for the different lods. This would naturally happen when going from 3d to cards. So you wouldn't be able to use static lighting with this at all. Just wanted to draw your attention to this.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    Obscura said:
    Hi. The foliage system in Unreal doesn't support different lightmap uvs for the different lods. This would naturally happen when going from 3d to cards. So you wouldn't be able to use static lighting with this at all. Just wanted to draw your attention to this.
    I see....thus *THAT* is why cards used as LODs of a full 3D grass patch show such a crappy lighting!! =O
    This means it's simply impossible....nice. Good to know.

    Thank you. ^^

  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Yes, with baked lighting, its impossible.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @zachagreg
    Ok, I think I'm slowly getting there....





    ....but the overdraw is still too prohibitive. =[

    I've found the setting you told me to switch and, with mip mapping off, the more distant grass strands' contours got grainy; but at the same time the overall overdraw improved by a good 20% (eyeballing it).
    A "quid pro quo", I guess.

    I couldnt arrange Grass_08 (the model you picked as a good start) the way you suggested, I dont think it would work out.
    Mostly because I'm having a hard time tracking each card in the screenshot, but also because I'm afraid the overdraw would be unbearable. Grass_08 has a VERY sparse amount of grass blades per card, transparent areas are everywhere...


    Instead I'm thinking of varying density and height within the same bundle.
    Tall, sparse strands on a card and short, denser ones on another. And maybe some loose triangles with single strands to dissimulate the regular edges of the external cards.
    Triangles that, being short, wont participate in the surface overdraw, and that I can recklessly remove in the LODs along with several of the shorter, more internal cards.
    This way, the only cards that will contribute to the overdraw will be the few tall ones, while the shorter ones should actually occlude the lower part of the bundle and limit the number of overlapping transparencies from a certain point up.

    Yep, it should work very well....it does, in my mind. But it's also true I'm going through an annoying flu and my brain is bathing in something like five gallons of phlegm, so....we'll see.

    More updates will follow. But probably not today. My head feels like a medicine ball. -.-
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    The circular ones are definitely looking better nice job. I highly suggest not doing it in the same bundle, rather as separate tall or small bundles of grass. Reason being is that once you put super tall inside of your normal grass bundle is now if you want to go through and edit the height of either you have to edit the height of all instead of just the one mesh. Don't be afraid of using multiple meshes/bundles, they can all use the same texture in the end anyways.

     Also if you were do it in the same bundle yes technically speaking would work, however you lose control of placement at that point you can no longer differentiate patches of grass. For instance large patches of weeds or taller grass or the smaller patchier grass found towards trails or roads which leads into a field. You only have your one highly varied mesh. I would say leave the mesh you have now alone, you have good variation in itself but what you need is mesh/bundle variation first and then dimension or scale variation in engine (via the foliage paint tool) when you are applying your grass to your environment.

    Try not to focus on the quad draw issue for right now. Let's get the look nailed down first and then we can talk optimization. I say this just because it is easier to learn one thing at a time and not get caught up in optimizing while you're still trying to make it look good.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    How about doing something like this?

  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @Obscura
    It's already cut more or less in that way, it seems we're surfing on the same wave.... x)


  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Just ran into this on artstation. I thought it might be interesting for you:
    https://80.lv/articles/creating-next-gen-grass-in-ue4/
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Obscura said:
    Just ran into this on artstation. I thought it might be interesting for you:
    https://80.lv/articles/creating-next-gen-grass-in-ue4/
    That's actually really awesome. I wonder what the drawbacks are then at that point then? If the drawcalls aren't hampering performance is there a reason not to do this method going forward?

    Especially with a culling distance of 5k getting 356% overall performance benefit over the big card method. Granted with a physics heavy scne or active AI occurring I imagine the drawcalls impacting the CPU would start to take more of a hit. I would've liked to see the stats for that scene that he showed in the GIF as well.

    However for portfolios and just general art making this is fantastic! Nice find Obscura
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @Obscura ; @zachagreg ;

    I feel like crying and laughing at the same time: this is a screenshot from september 2018, when I was already testing the idea of skipping cards altogether and using a "pure mesh" approach instead.



    It was mostly a test and I didnt think too much about polycount/shadows, just wanted to see what would have happened to overdraw and shader complexity.
    I ditched the idea because I couldnt achieve a satisfactory density and lushness while keeping a good FPS, but I guess I could give it another try, now. x)

    Anyway, I'll also try to create mid-tall grass type using "tight cards". Basically the kind I created in the latest update, but with separate cards for each strand.

    Correct me if I'm wrong, though, as I believe the "tight cards" approach is good only for the kind of tall grass that always stays perfectly upright. Bent strands would require extra polygons(?).
    Same goes for the "pure mesh" type, unless you wanna spend up to 13 tris for each strand like I did in my very first test (madness, I know!). I guess...?

    Also, he mentions not using shadows, but then he shows 4 gifs of some "game ready" scenes of his and I noticed pretty sharp shadows cast by each and every strand.
    I see contradiction, there, or maybe my fading flu is still bogging down my mind and I missed some relevant detail...?

  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Remember the one thing he did say in that article is that the pure mesh approach is only good for grass that is very simple. 

    Also the tight cards can be used for a lot of different types of grass from the looks of it. I believe that giving those taller pieces of grass their own tight cards allows for a greater level of realism due to the nature of tall strands of grass waving a different way in the wind. 

    @Obscura Would the overdraw be reduced if a camera based system were implemented similar to Horizon Zero Dawn's? Haven't had a chance to test it yet but it kind of makes sense in my head that having the cards curve from lying flat to straight up as the view gets away from the camera would reduce overdraw some what.

     

  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    I've tried tight cards with a handmade strand, just as a test, and it's....plainly terrible.
    What you see here are patches of 2 meters in diameter covered in strands 20 to 40 cm tall, 2 to 6 tris per strand. About 4.8k tris per patch.



    This is what it looks like without mipmapping. This screenshot cannot deliver the painful graininess of the strands waving in the wind.
    Unbearable!

    With mipmapping on, instead, the strands simpy disappear into thin air few meters away from the camera, which is obviously unacceptable.

    This is not a viable solution, unless some wizard descends upon us to cast his unfathomable knowledge on me.
    I'm moving on to testing mixed size/density cards....

    And yes, the goal is still to achieve a lush, dense grass type, performant enough to cover whole fields without melting a GPU.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    @zachagreg - Probably not much.

    Alright, so weird enough, I was just experimenting with foliage these days, and I can tell you guys, those colorations in the debug views should be changed, as we are having way stronger hardware now. The problem with the detailed meshes is clearly the vertex/tris count, but overdraw created by overlapping alpha tests, has somewhat different effect on current gen hardware than one from say 5 years ago. I'm using medium sized planes for my grass and per leaf plane for my tree in my scene, the debug views shows red/white here and there and I have more than 200 fps on a gtx1080 on 1080p. So long story short, I would say try to find the balance between what looks good vs what renders fast. So in your case, this should be fine:


    You can uncap the fps by typing "t.maxfps 200" into the console for example to see the real performance.

    Anyways, you should match the underlaying tiling texture to the actual grass better. It helps hiding the seams and you won't need to much density to make it look good. At least you should use the same hue/sat or similar. This will also hide the culling a lot better.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @Obscura ;
    That grass looks bad, to me, and I keep giving my attempts a green-ish colour just for the sake of being morally allowed to call them "grass".
    If it cant stay above 100-110 on a GTX980Ti when all you see is the terrain and some good looking grass, achieving 180fps when the grass looks like something that came out of the rear end of a bovine is no achievement.

    The underlying terrain texture was a test itself, this is all about learning (Substance Designer, in that case).

    It's not good yet? Double effort!!

    Brb with my next attempt.


    PS: could you share a screenshot of your grass? I'm interested.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Here it is:
    https://polycount.com/discussion/209623/smooth-foliage-like-in-breath-of-the-wild-europa-by-helder-pinto-mini-tutorial#latest

    I think I mentioned, its a very different art style, but I'm tackling the same issues with them and I'm seeing similar results to yours in the debug views. For example this is how my  plane density looks like:


    This gives me such shader complexity with dithered alpha test:


    And such quad overdraw:


    Lit view:

    Keep in mind, its a different style, but performance rules are general.

    While I have around 200 fps regardless of the view. So I would say take these buffer values with a grain of salt, especially considering current hardware. Obviously, its bad if its all white, but your one on the picture I re-posted, should be similar to this with reasonable density. Also, consider matching the underlaying texture ;)

  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    Ok, this is so much better that I'm gonna give myself a treat..... *^^*





    LODs are handmade to ensure a reduction in polygons only where it doesnt cause a discrepancy between near and distant bundles; even the transition is barely visible, and only if you focus on it. =)

    Performance modes...
    (Dont mind the FPS in "lit mode", it was because I was bringing up the screenshot software, it's actually between 100 and 110!)





    It still shows some straight lines, when looked at from above, but now I know how to break those lines and make them virtually unnoticeable.... ^o^




    Two odd things:
    1) the FPS in "Play mode" is better than in edit mode....the heck I understand why...
    2) the FPS is better with the alpha map's mip mapping on...seriously, there's a huge difference and obviously the visual quality is better too. Maybe it needs some investigation? *shrug*
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Looking good it will look even better with some color, height and plant variation. The mipmapping being disabled is case dependent and not a blanket thing. Sometimes the density of a patch of grass or field will show no difference in visuals but a difference in performance due to the mipmapping occuring. 
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    1, That depends if you are playing in editor viewport or standalone. In editor, there is a lod of overhead from editor UI, even on smaller viewport. So ideally, you want standalone mode on full screen for real performance debugging.
    2, That makes sense,you do a lot of over sampling when mips are off.

    You can also gain some performance in editor by simple going into "game mode" by pressing the g button while the viewport is in focus.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    I think you should also make different foliage presets so they don't get fully culled over distande. That, and matching the texture should make a lot of good. But to be honest, that darkness coming from something, the one one the bottom of your grasses are also making them looking more unnatural. This is especially visibly from top and far view. The matched texture would help this somewhat but you should not make them intentionally darker because this will be visible due to how shading works. I use the dithered alpha test to hide intersection even more. Even on your Cry Engine example, on the foreground, the intersection is distractingly visible. It has an unnatural blend. I'm not saying to fully fade them, but making them dark like that clearly doesn't help :D
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @zachagreg ;
    The first step was managing to craft a tall, dense, good looking grass. Which I think I accomplished.
    Second step will be improving it visually with other types of grass as you've already suggested. I think I'll actually pick two or three weeds from the pic you posted! ^o^
    I'll also try to give strands some colour variation, but nothing too flashy or it might make repetition noticeable.


    @Obscura ;
    The type of grass I'm trying to achieve is completely different from yours, I can see why tilting the cards to such extreme angles worked fine for you, consequently giving you less issues with overlapping transparencies.
    Thanks for the heads up about the different performance levels between edit, play and stand alone modes. I shall take that into account. =o

    What do you mean with "foliage presets"? What is that? And how would that prevent full culling over distance?

    Actually, I made the lower part of the grass darker just because I planned to try turning shadows off so to chip off some more performance. You say it's better to spend a bit more on shadows and let them do the job? Or maybe make them just a bit less dark? =o
    Yeah, I didnt like how grass looked at its root, in the Cry Engine example. Cards were very distinguishable. But I liked how they blended in the upper part, where it was no longer possible to tell cards apart.

    How do I dither the alpha map? I'd like to give it a try and see how it looks.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    If you're really dead set on turning off shadows for LOD 1 or 2 you can try just doing a linear object gradient on the Z-axis instead of putting the darkness directly in your maps. This would increase instructions though on the shader so you'd have to test whether or not it would be beneficial to performance.  I'm with obscura on that, foliage needs a nice no lighting albedo.

    For the dither you can throw a Dither Temporal AA on your opacity mask.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    zachagreg said:
    [....]  I'm with obscura on that, foliage needs a nice no lighting albedo.

    For the dither you can throw a Dither Temporal AA on your opacity mask.
    Oky, will avoid colourisations other than plain base colour.

    But how do I activate the dither?
    Also, I hate AA, it takes away hard edges, but also details from the textures... =p
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    This is what I believe @Obscura is talking about.

    https://www.youtube.com/watch?v=ieHpTG_P8Q0&nbsp;

    Please correct me if I am wrong. In that video it's not AA in the traditional sense that you normally would talk about AA. The dither temporal AA is what causes the opacity mask to dither.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Yeah. I used that on the root of my grass cards to have softer transition. You can also enable dithered lod transitions to made the lod change less evident. These only work correctly when taa is enabled though.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    Weeds, wild carrot....



    The dithered transition is interesting, but the video is not very explanatory. How do I integrate it, with a camera-pixel distance node?
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    The dithered lod transition can be enabled in the material properties. 
    About fading them at culling:
    https://www.google.com/search?rlz=1C1GCEU_enHU838HU838&q=unreal+engine+foliage+dither+fade&spell=1&sa=X&ved=0ahUKEwieiMqqzIvhAhWP_CoKHWMQAjwQBQgoKAA&biw=1920&bih=969

    Root fading can be done by enabling the dithered opacity mask option in the material properties, and then hook up some vertical gradient to the opacity mask input. I used the V channel of my texture coordinates and applied some power on it to push the dark part of the gradient to the root of the grass cards.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @Obscura ;
    About dithered culling.
    I've tried following the examples in the forum thread that comes up as the first result in the google search page you linked me. The results vary from "nope" to "not worth fiddling with it any longer".
    I might be doing something wrong, but after playing with a simple PerInstanceFadeAmount node for a bit I've decided the resulting effect is more than acceptable (given the overall quality of my grass).

    The concept is intriguing, but I believe it's something more suitable for single cards grass strands, and not for the classic billboard approach.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    Weeds, dandelion flower....




    But something's not working as intended, once placed in the world....

    [ Unlit ]

    [ Lit ]



    For some reason the flowers get darkened, when lit, but I can understand what causes it.
    Also, it's not a homogeneous darkening, it looks like it depends on the direction they bend toward.
    Shadow casting is off.

    @zachagreg
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Is that baked lighting or dynamic? It doesn't look like light mapping issues to me.

    It may possibly have to do with your normals and whether or not its two sided, but lighting first.
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @zachagreg ;
    I have no idea how to tell whether it's baked or dynamic, but I doubt it's baked, since it's not always the same flower that gets darkened.....




    Also, it looks pretty normal in the preview pane in the mesh properties window....




    This is the master shader I composed for this type of foliage....



    The base textures are all a 16x16px placeholder crafted just for this purpose.
    They're all turned into parameters, so that all I have to do for each new foliage mesh is create an instance and fill in the actual textures.
    "Fillers" are just full white 3vectors tha can be turned to 0 when there's an actual texture input.
    The TwoSidedSign node is there, as you can see.

    It's really just about what direction each flower faces, in fact sometimes it's the taller flower, sometimes the shorter one and sometimes they're both darkened.
    And yes, it's a 2sided material, otherwise you'd notice transparent elements like the stem and the bottom face of the petals.

    And these are the vertex normals, I didnt manipulate them....




    EDIT (2019.03.20 02.34): Apaprently, it has something to do with the material, but I just cant understand what it is.
    I've tried making a stand-alone material and it works fine....



    The heck I know why, though. =p
    I shall investigate the issue....unless you already know the answer. ^^
    @Obscura ; you?

  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    For the baked/dynamic it'd be whatever your lightsource is set to currently paired with however you're placing these in your level. What you see in the preview pane is completely dynamic. If it is Movable it is dynamic, static is baked, and stationary is a hybrid including baked lighting with dynamic shadows. This isn't happening on your wild carrots correct?

    Separate note: It's probably better to use a switch node instead of the add filler option you currently have. Less instructions in the long run.

  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Switch makes more shader permutations. Add is almost free on modern hardware.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Obscura said:
    Switch makes more shader permutations. Add is almost free on modern hardware.
    I won't side track this thread asking why. But if you could link something for that it'd be awesome. I believe you, it's just good to learn. Always thought general rule is less instructions is better.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    Switch makes a branch in the shader. Basically you need to compile 2 versions if you have one branch. Its also called "static" switch, because of the branching, the versions needs to be pre-compiled, and it won't compile the another versions at runtime. This is why you cannot change the switches value in game. If you have a lot of branches, you will have a lot of shader code for the versions which makes them using more memory. 

    Also, similar instructions will be collapsed into a single instruction by the compiler. For example, chaining up 5 adds will be 1 instruction at the end.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Ah I see, as not to derail this thread I'll post another thread later after I read some of the documentation over and some resources I found on the topic and post any questions there since I know I would like to know more and ask some questions. But another time. :)
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @zachagreg ; @Obscura ;
    Actually, I got the same idea as zachagreg, I've replaced the add/multiply nodes with "parametric static switch", which does the same thing as the static switch, but through a manual parameter (you tick a box in the instance).

    This said, I still have no idea what makes the instanced master generate that odd shading while the stand-alone material works flawlessly.

    [ MASTER ]


    [ STAND-ALONE ]


    As you can see I've over-simplified the stand-alone material (very little parameter'd values) to speed up the test, but everything's there. And it works just fine.

    The UV coordinates node in the master was just a test to take out every possible cause that came to my mind. Did not change anything.
  • Obscura
    Offline / Send Message
    Obscura grand marshal polycounter
    I can see that you use 0.5,0.5,1 when normal map is disabled. This is wrong and I guess this makes the wrong shading. You should use 0,0,1.
  • zachagreg
    Offline / Send Message
    zachagreg ngon master
    Obscura said:
    I can see that you use 0.5,0.5,1 when normal map is disabled. This is wrong and I guess this makes the wrong shading. You should use 0,0,1.
    Would that affect anything if he has that switch turned on to use the normal map instead of the value?
  • Steamy_Steve
    Offline / Send Message
    Steamy_Steve triangle
    @Obscura@zachagreg ;
    As zachagreg said, it shouldnt affect the lighting anyway, when I plug in an actual normal map.
    Also, where did you get that 0,0,1?!

    For all I know, which is not all but it's not little, the *flat* normal map colour is halfway red (128), halfway green (128) and full blue (255).
    If you set red and green to 0, basically you're telling the engine that the surface is fully tilted toward the upper-left corner of the UV (in DicrectX).


    This is the same surface under a perpendicular light source, but with different normal colours...

    [0, 0, 1] Full Blue


    [0.5, 0.5, 0.5] Grey


    [0.5, 0.5, 1] Normal map flat colour


    Anyway, no, it cant be the normal map, because light bounces just fine in the mesh's preview pane.
    It has something to do with how light is calculated when the mesh is placed as foliage into the world.

    Could it be because I didnt set the metallic value? I highly doubt, but I'll check....


    EDIT (2019.03.22 03.15): I've spotted the culprit!
    It was the normal map "placeholder". The texture node's sampler type wasnt set to "Normal" (detail I never had to set because of UE4's inherent automation).
    Now everything's fine, with weed_02's lighting.

    @Obscura ;
    What about "Static Switch Parameter"? Does it add up to the shader instructions as much as the normal "Static Switch"? Or is it lighter, since it's set before compiling and cant be changed after (can it)?

    @zachagreg ;
    I seem to remember you telling me something about baking alpha maps for foliage in Substance Painter, but maybe....it wasnt you? And/or it wasnt SP?

    My next attempt at weeds will be aconite...
1
Sign In or Register to comment.