Announcement

Collapse
No announcement yet.

Distance Field Data to remove grass

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

    Distance Field Data to remove grass

    Would it be possible to use distance field data to remove grass?

    Currently my foliage intersects a ton of meshes and will poke through things like rocks which looks terrible.
    I saw a blueprint that used distance field data to create flow maps for water so I was wondering if it could be used to remove landscape grass.

    Has anyone tried something like this? I'm pretty swamped with work at the moment so I havent had a chance to figure out how to approach this if its even possible.

    #2
    Sounds like a good idea. There are some limitations what stuff work for with grass output but it should be quite easy to test this. You probably want to offset sample position z to bit upward to avoid intersections with landscape.

    Edit: Another way to mask grass would be new ambient occlusion mask from lightmass.

    Comment


      #3
      After some testing I have confirmed that I have absolutely no idea what Im doing. I figured I would take the layer sample and subtract from that the distance field data but the grass either disappears altogether or just doesn't do anything.

      Comment


        #4
        Show your material then? It should be fairly easy.

        Pseudo code:
        grassWeigth = clamp(GetDistanceToClosestSurface() * 0.02 - 0.5 ,0.0, 1.0);

        This would spawn grass to places where there are none surface in 0.5m radius with soft gradient to 1m.

        Comment


          #5
          This is what I had.
          Click image for larger version

Name:	DistGrass.JPG
Views:	1
Size:	164.1 KB
ID:	1087357
          I plugged the result into emissive color and it shows up properly as far as I can tell. The grass should spawn in the white areas but It doesnt.
          Click image for larger version

Name:	DistGrass2.JPG
Views:	1
Size:	45.3 KB
ID:	1087358
          Last edited by KrunkFu; 09-10-2015, 02:34 PM.

          Comment


            #6
            most likely, the distance to nearest surface node cannot be evaluated properly by the grassmap rendering system. The issue is probably that the distance to nearest surface uses the global distance fields which use cascading resolution away from the camera. during grassmap rendering the camera is probably either undefined or defined to be way high in the air or something like that, which causes invalid results from the clipmap lookups. It may be possible to make this work by always using the lowest resolution clipmap for grassmap baking, but the only engineer capable of working on this (DanielW) is out on vacation right now. I will bring this up when I see him next.
            Ryan Brucks
            Principal Technical Artist, Epic Games

            Comment


              #7
              Thanks for explaining! Any changes to the landscape grass output that give artists more control are welcomed.

              Comment


                #8
                I agree something like this would be really useful. I was going to try something similar for baking flowmap data.

                One way to test if any distance field data is read by the grass system would be to add a movable static mesh to the world. Those still use their individual high resolution distance fields and do not get composited into the global fields. I forgot about that in my reply yesterday. It may be a different issue preventing it from working if that doesn't work.
                Ryan Brucks
                Principal Technical Artist, Epic Games

                Comment


                  #9
                  I made some of the rocks moveable and it didn't make a difference. I tried everything I can think of and nothing has worked. There are several ways of spawning grass (landscape grass output, foliage painting, and the procedural foliage spawner) is there any way to leverage the functionality of those other tools to refine the results of the landscape grass? Can any of the distance field information be baked down to a texture?

                  Comment


                    #10
                    Any information how grass baking is actually working would help. Is it done on gpu?

                    Comment


                      #11
                      For every grass type in the material editor, the engine renders a density map into a 2D texture that is then used on CPU to spawn individual instances. So the part where the distance field would have to be used is the rendering of "grass" density map into a texture, which is the step that Ryan thinks wouldn't work correctly at the moment.

                      Comment


                        #12
                        Did anything ever come of this? Did DanielW have anything to say about it?

                        Comment

                        Working...
                        X