Announcement

Collapse
No announcement yet.

I see the Grass only in a Round Area from the Player

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

    I see the Grass only in a Round Area from the Player

    Hello,
    i hope someone has a Solution for this Problem.
    My problem can you see in the picture. The grass is only visible in the round area (around the Player).
    But I want the grass to be visible infinitely far away. What do I have to rearrange here?
    Kind regards,
    halobungieClick image for larger version

Name:	Problem.jpg
Views:	291
Size:	279.2 KB
ID:	1716654

    #2
    I think you have no mesh in LOD1, so you see only LOD0

    Comment


      #3
      Thanks for this tip - but how can i solve this?

      Comment


        #4
        Hi, LODs won't make any difference, if you don't have a LOD1 then LOD0 will used. You should make sure you have LODs though (if not you can generate them in unreal engine), cause when the grass is further away you can reduce the poly count and maybe use a more simple material (that's what LODs are for). If you open the static mesh you can scroll down to LOD Settings.

        Click image for larger version

Name:	lod.png
Views:	396
Size:	34.0 KB
ID:	1716748

        As for your problem: as far as I know all instanced static meshes do have a start- and end cull distance. Therefore if your grass is further away than this cull distance from the camera, it will be culled. UE doc https://docs.unrealengine.com/en-US/...age/index.html look under culling

        So there are several things you could do:

        1) increase the cull distance to as far as you can see (I wouldn't recommend this cause this will be a strain on your performance)
        2) use per instance fade amount in your material to make the transition smoother (if the distance is below Start Cull distance, then the per instance fade node will output 0, and if the distance is End Cull distance the output will be 1 and it will be lerped in between).
        Click image for larger version

Name:	per_instance_fade.png
Views:	318
Size:	457.3 KB
ID:	1716749

        3) use the color of your landscape in your grass or
        Click image for larger version

Name:	landscape_color.png
Views:	321
Size:	439.9 KB
ID:	1716750
        4) use a combination of 2) and 3), so use the color of the landscape as transition to the End Cull Distance utilizing the per instance fade node
        Click image for larger version

Name:	perinstancefade_plus_landscape_color.png
Views:	312
Size:	448.6 KB
ID:	1716751

        2) is the easiest to setup, 3) is a bit more complicated cause you need to capture an image of your landscape first (using a scene capture component 2d) but if you have 3) then 4) is again easy to setup

        I used something like this for 3) https://forums.unrealengine.com/deve...olor-for-grass

        Comment


          #5
          For 3, you can also just paint grass layer with the grass node of a different color then the other portion.

          To match the grass it's best if your grass mesh is colorless, your terrain mesh is colorless, and you inject a specific hue of green into them via MPC.

          Keep in mind that the default grass from the content examples literally destroys your performance.

          Comment


            #6
            Originally posted by chrudimer View Post
            Hi, LODs won't make any difference, if you don't have a LOD1 then LOD0 will used. You should make sure you have LODs though (if not you can generate them in unreal engine), cause when the grass is further away you can reduce the poly count and maybe use a more simple material (that's what LODs are for). If you open the static mesh you can scroll down to LOD Settings.

            Click image for larger version

Name:	lod.png
Views:	396
Size:	34.0 KB
ID:	1716748

            As for your problem: as far as I know all instanced static meshes do have a start- and end cull distance. Therefore if your grass is further away than this cull distance from the camera, it will be culled. UE doc https://docs.unrealengine.com/en-US/...age/index.html look under culling

            So there are several things you could do:

            1) increase the cull distance to as far as you can see (I wouldn't recommend this cause this will be a strain on your performance)
            2) use per instance fade amount in your material to make the transition smoother (if the distance is below Start Cull distance, then the per instance fade node will output 0, and if the distance is End Cull distance the output will be 1 and it will be lerped in between).
            Click image for larger version

Name:	per_instance_fade.png
Views:	318
Size:	457.3 KB
ID:	1716749

            3) use the color of your landscape in your grass or
            Click image for larger version

Name:	landscape_color.png
Views:	321
Size:	439.9 KB
ID:	1716750
            4) use a combination of 2) and 3), so use the color of the landscape as transition to the End Cull Distance utilizing the per instance fade node
            Click image for larger version

Name:	perinstancefade_plus_landscape_color.png
Views:	312
Size:	448.6 KB
ID:	1716751

            2) is the easiest to setup, 3) is a bit more complicated cause you need to capture an image of your landscape first (using a scene capture component 2d) but if you have 3) then 4) is again easy to setup

            I used something like this for 3) https://forums.unrealengine.com/deve...olor-for-grass
            Hello chrudimer,
            Many thanks for your extensive help!
            Can you show me Please your settings for the Cull Distance in a Picture for Lod 0, Lod 1, Lod2 etc.
            At this time i don't understand this Cull-Settings.

            Kind regards!!

            Comment


              #7
              Sure. The Cull-Distance has no relation with the lods. Those are two separate things.

              Some doc on lods: https://docs.unrealengine.com/en-US/...ODs/index.html
              What lods do is they change the mesh based on distance. So when you're further away from the mesh it changes from lod 0 to lod 1, then to lod 2, ...
              So if you would have a tree then in lod 0 it would have maybe 20k polys and 3 materials, in lod 1 only 5k polys, in lod 2 only 1k and would be an imposter as lod 3 (so only 4 polys and one material).

              End Cull-Distance means that when the mesh is further away than this distance it will be culled regardless of the lod. As far as I understands it Start Cull Distance does nothing except that you can use the per instance fade node in your material to manually set up the transition.

              I assume you're using the grass directly in the landscape material (landscape grass output), then when you open up the landscape grass type you can change the Cull Distance settings. Those are the settings I used for 4)
              Click image for larger version

Name:	culldistance_landscapegrass.png
Views:	359
Size:	65.0 KB
ID:	1716962
              But to get a smooth transition between start and end cull distance you would have to manually set it up in your material utilizing the per instance fade node.

              Comment


                #8
                Originally posted by chrudimer View Post
                Sure. The Cull-Distance has no relation with the lods. Those are two separate things.

                Some doc on lods: https://docs.unrealengine.com/en-US/...ODs/index.html
                What lods do is they change the mesh based on distance. So when you're further away from the mesh it changes from lod 0 to lod 1, then to lod 2, ...
                So if you would have a tree then in lod 0 it would have maybe 20k polys and 3 materials, in lod 1 only 5k polys, in lod 2 only 1k and would be an imposter as lod 3 (so only 4 polys and one material).

                End Cull-Distance means that when the mesh is further away than this distance it will be culled regardless of the lod. As far as I understands it Start Cull Distance does nothing except that you can use the per instance fade node in your material to manually set up the transition.

                I assume you're using the grass directly in the landscape material (landscape grass output), then when you open up the landscape grass type you can change the Cull Distance settings. Those are the settings I used for 4)
                Click image for larger version

Name:	culldistance_landscapegrass.png
Views:	359
Size:	65.0 KB
ID:	1716962
                But to get a smooth transition between start and end cull distance you would have to manually set it up in your material utilizing the per instance fade node.
                Hello chrudimer,

                thanks Again for your kind help!!!

                And yes, you have right, i'm using the grass directly in the Landscape material! It's the Landscape-Material from the Marketplace-Content: "Procedural Ecosystem".

                Can you show me Please a Picture from your Landscape-Material where i can see this: "per instance fade amount in your material to make the transition smoother"?

                Kind regards!
                halobungie

                Comment


                  #9
                  Sure I can help you to set it up.
                  Click image for larger version

Name:	grass_material.png
Views:	397
Size:	158.6 KB
ID:	1717135
                  That's in the material I used, but you will need more than the material to get it working like in 3) or 4), therefore I think it is better when you try doing it yourself and when you hit a problem you can post the code and I can help you from there, cause there are several things you would need and adapt some variables to your own project therefore you would need to understand it to some degree to get it to work in your project.

                  So you would need several things to get it work like in 4):

                  1. Per Instance Fade node inside the material to get a smooth transition
                  2. a texture of your landscape color, cause you want the grass to fade into the landscape at a distance
                  3. a scene capture component 2d and a rendertarget to get 2. (to generate a texture of your landscape color)

                  So first to 1:
                  Basically you should understand how Per Instance Fade and Start- End Cull Distance work. In this epic live training they're talking about this https://www.youtube.com/watch?v=PDlGKZ1c3Zc You should watch at least from minute 7. They're using the SM_Bush from the startercontent and I would recommend that you redo their material and play around with the parameters and the Start- End Cull Distance to get a feeling how this works.

                  2/3. You would basically need do something like in this video https://www.youtube.com/watch?v=a9iho861SlY
                  But you would put the scene capture component 2d into a blueprint and rotate it to face downwards. Further you would need to make the camera orthographic and the Ortho Width would be the size of your landscape.
                  Click image for larger version

Name:	scene_capture_component_blueprint.png
Views:	258
Size:	46.5 KB
ID:	1717136

                  From the Render Target you can then right click -> Create Static Texture (in the texture you should then uncheck the alpha if you want to see it in the editor)
                  That would be your landscape texture.
                  Then in the material you would need to project the world position (where the grass is) onto the UV-Space of the texture. 10th-comment from the top https://forums.unrealengine.com/deve...olor-for-grass but you should read it all.

                  The Get World Position Node returns the world position as RGB (red is the x-position, green is the y-position and blue is the z-postion). Cause you rendered the landscape texture orthographic you only need the x and y position of the grass currently rendered. Therefore the component mask. Then you would need to project this (x, y) value to the (u, v) value of the texture. The texture coordinates go from 0 to 1.
                  Click image for larger version

Name:	uv_coordinates_of_a_texture.png
Views:	247
Size:	9.4 KB
ID:	1717137
                  So the upper left position of your landscape would need to be projected onto (0, 0) and the ortho width of your scene capture component 2d would be the width (from (0,0) to (1,0)). Therefore you would need to subtract the world position from the upper left position of the landscape and divide it by the ortho width.

                  So you would need some understanding of the material editor to set this up

                  Comment


                    #10
                    Hey, not to knock your render target approach, but just how big of a resolution are you using on this RT file?

                    Any TextureSample above 2k res used within the landscape material seriously cripples performance on decent machines rendering 4k res. It sort of creates a bottleneck which I think is more due to poor implementation of LODs on the landscape system then the material itself.

                    Also, since my setup is nearly identical but I get rather poor performance with it, I'd be curious to know if you benchmarked any of it, and what sort of ms render time you are seeing on a completed scene at whatever your desired target res.

                    Assuming you both aren't already minimizing overdraw, I would also like to divert both of you to a better way to do all of this in 2020, one that won't load GPUs as much with transparencies.
                    https://80.lv/articles/creating-next-gen-grass-in-ue4/

                    the article shows different benchmarks to prove the point - it's cheaper to have more tris on screen then to use the transparencies/masks.

                    The same system you are using can be adapted to minimize the transparency overlaps as shown in the article in order to get better performance. Ofc, some nodes on the grass would become irrelevant.

                    Last but definitely not least, for OP, sign on to the academy from the Learn tab on the website, and pull up the master material course.
                    There is a whole video where Sjoerd De Jong walks through a grass material and explains a couple tricks, like masking wind with vertex painting.

                    Comment


                      #11
                      Hey, thanks for the input. I did nothing to reduce the overdraw of my grass and its blue (1 to 2) close up and goes up to 4 when further away (I remember from 4.22 that my grass shader complexity goes up to purple/white purple though due to overdraw).

                      I'm using a 4k texture on a 2x2km map (so a precision of 1/2m). I see no difference in GPU render time between using this texture and not using it (static switch in the grass material) either at Full HD or 4k rendering resolution. The GPU memory usage increases by around 24mb though.

                      Also, since my setup is nearly identical but I get rather poor performance with it
                      Are you updating the RenderTarget at runtime? If so that will seriously cripple your performance at 2k . I took the shoot once and then created a texture from it which I use then.
                      Also I'm using the texture in my grass material not the landscape material. Would you mind sharing more information about you're setup?

                      By the way do you know any way to access the material of the grass spawned by the landscape grass node during runtime?
                      Cause then you could swap the texture containing the landscape color during runtime, and then a 1k texture resolution (or even less) would be sufficient (at a precision of 1/2m that would mean a max cull distance of 128m).
                      With the foliage from the foliage painter you can access that through the "InstancedFoliageActor", but I haven't found anything for the landscape grass...

                      Comment


                        #12
                        I was using a single rendered image at 2k res for the distance area. Aligned to landscape on a map less then 1km.
                        after that wasent as performant as I need I just swapped the landscape material and acrually paint grass types on each other carefully. I have a no procedurals layer that is always subtracted from all the grass nodes making it possible to remove them from an area as well (good for clearing up around rocks or changes in vegetation).
                        My non optimized mesh performs poorly but looks good. The grass shader is full of things like normal wind (looks like the grass moves in distance but the color just shifts around because of the normal map in use). For all intensive purposes I guess it runs OK. Just cant expect the full scene with a lot of trees and other plants to run 60fps at 4k.
                        For several reasons I'm optimizing slowly (one being double material slot on tree instances, before the impostor).

                        I'm also starting to think the size of my map and number of components may be an issue - I tested different options, all of them seem pretty equal, even non suggested sizes.
                        In the process I found that world composition makes render times slightly worse - on the exact same map size (only one tile loaded) vs loading just the map manually.

                        I am now (I was before too, but I hadn't played RDR2 before xmas, so I always kind of assumed some popping was acceptable) attempting to essentially create a similar environment to red dead 2 in terms of grass and non-popping lods.
                        The meshes with single grass blades outperform the full on grass mesh by a lot - with the same material on them.
                        they are however sized a bit different. 2mx2m, 1mx1m and 25cmx25cm. I paint the 1m and 25cm manually where the 2m pops out of the landscape due to angle.
                        So far no LODs, and with just landscape and grass around 90fps at 4k.

                        Re
                        The best way to change the grass material without having to make a mess is to use a material parameter collection.
                        I use that already for 3 things, seasonal coloring, wind, and passing in the actor location.
                        To swap a texture I would use a render target and update the image by writing a different texture to it based on some distance logic.
                        it's not rendered or captured so the cost for writing to it just once is fairly low.

                        Comment


                          #13
                          Ah, thanks I already used parameter collections, but I didn't think about overriding the RT and use that as texture.

                          Comment


                            #14
                            Originally posted by chrudimer View Post
                            Ah, thanks I already used parameter collections, but I didn't think about overriding the RT and use that as texture.
                            It's just Going around problems of accessibility. If only it were easy to detect the base item via BP you wouldn't need to have these insane workarounds...

                            Re the grass material you asked info on
                            Gigantic mess from afar:
                            https://gyazo.com/99ce20e01f2992ff22c857f034e06c16

                            getting into it a bit
                            Normal winds
                            https://gyazo.com/9dadcbe884fba6d71b8b7bdde6dddaf7

                            Mixed to vertex color + normal (output goes to normal)
                            https://gyazo.com/9ffd29d3ab7d980c87560aeec0faabda

                            Camera fade
                            https://gyazo.com/2d54a7deab5654ba9bb702ad52d25dc4
                            UV1 is used in the normal above to do this. (moving calcs to a UV solves some performance, though not by much in this case).

                            Per instance fade (requested by op originally)
                            https://gyazo.com/a7df21a2e043dac7714fdc37b43dcee9

                            The rest of that mess is just the color setup for changing with the MPC.


                            Most of that setup is actually shown in the Learning tab within the master materials section I think. I modified the normal winds for my needs a smidge but the theory was simple enough. The scale of the normal map affects the offset you see in color.
                            The normal map itself is usually something simple - take a picture of clods, convert it to a normal. or waves, waves work good. I think the tut uses the water form Boy and his Kite.

                            This is the effect of that material with a blank texture on the vertex version of the grass (no transparency at all), colored for debug.
                            https://gyazo.com/e121f6d76ec50faf2fa8db5287090343
                            And I also gained 20fps swapping the mesh :P

                            Last edited by MostHost LA; 02-09-2020, 02:29 PM.

                            Comment


                              #15
                              Thank you very much!
                              And yeah, I think Dither Temporal AA would be the fastest way to set the per instance fade up.

                              Comment

                              Working...
                              X