Announcement

Collapse
No announcement yet.

Blending POM

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

    Blending POM

    The parallaxocclusionmapping node only recieves a texture object into the hieghtmap texture input. I was trying to get a vertex paintable mask of a moss material to add to the parallax value/height value. You cannot perform math functions on the texture object. Is there a way around this?
    pschwaegerle@gmail.com
    https://www.artstation.com/artist/peterschwaegerle
    www.peterschwaegerle.com

    #2
    I also remember running into this issue when experimenting with POM. Don't remember ever finding a solution, so I'd like to know as well.

    Comment


      #3
      I think content examples do show an example of blending two textures with pom.

      You need to blend textures, that are sampled after the pom node, thus you would need to place two POM nodes for two layers, and lerp the resulting textures.


      As you can see, it also doubles POM performance cost.

      There is a much more optimized way of blending up to 4 POM layers, but that requires basic understanding of the code behind POM.

      Comment


        #4
        Originally posted by Deathrey View Post
        There is a much more optimized way of blending up to 4 POM layers, but that requires basic understanding of the code behind POM.
        Couldn't you just pack POM maps into the R, G, B, and A channels and then use Lerp "masks" based on whatever differentiating rules you wanted to control what POM goes where (i.e. angles/heights/surface types) to control which Heightmap Channel is referenced?

        I.E. use a Make Float 4 node and have lerp masks determining the 1/0 values for POM with the texture-packed POM T2d channels as references to essentially make a custom POM Heightmap.

        Comment


          #5
          Originally posted by hippowombat View Post
          Couldn't you just pack POM maps into the R, G, B, and A channels and then use Lerp "masks" based on whatever differentiating rules you wanted to control what POM goes where (i.e. angles/heights/surface types) to control which Heightmap Channel is referenced?

          I.E. use a Make Float 4 node and have lerp masks determining the 1/0 values for POM with the texture-packed POM T2d channels as references to essentially make a custom POM Heightmap.
          I don't think I fully understand what are you talking about.

          Comment


            #6
            I was trying to get a vertex paintable mask of a moss material to add to the parallax value/height value
            I think the theory is that per-vertex data could just move the vertex, rather than use the more expensive per-pixel movement.
            Also, moving vertices means that you will cast better shadows.

            Comment


              #7
              Originally posted by Deathrey View Post
              There is a much more optimized way of blending up to 4 POM layers, but that requires basic understanding of the code behind POM.
              Where can I read more about it?

              Comment


                #8
                Originally posted by Deathrey View Post
                There is a much more optimized way of blending up to 4 POM layers, but that requires basic understanding of the code behind POM.
                Can you please give a link on it?

                Comment


                  #9
                  Originally posted by hippowombat View Post
                  Couldn't you just pack POM maps into the R, G, B, and A channels and then use Lerp "masks" based on whatever differentiating rules you wanted to control what POM goes where (i.e. angles/heights/surface types) to control which Heightmap Channel is referenced?

                  I.E. use a Make Float 4 node and have lerp masks determining the 1/0 values for POM with the texture-packed POM T2d channels as references to essentially make a custom POM Heightmap.

                  You can do this, if you also control the input going into "Heightmap Channel". There will be some 'floating' type artifacts if you do it like this though. The reason is that the blend point between the channels will only be evaluated once, at the surface level. To be correct, it needs to be re-evaluated again at every iteration and there is no easy way to do that without having the alpha itself as a texture object for multiple lookups.

                  The 'floating' aritfacts can be minimized by using wider blend gradients between the different channels.

                  The 'correct' way to do this is by performing POM on each heightmap separately, and ALSO ray marching the blend alpha map rather than pre-applying it. That is not very easy to do without doing a double POM which is expensive though. And its not possible at all for vertex paint or landscape where you don't have texture objects.
                  Ryan Brucks
                  Principal Technical Artist, Epic Games

                  Comment


                    #10
                    I ended up using simple max blend on the channel-packed heightmaps. Blend map is also offset at constant mean height value. Not completely drift free, but works acceptably at low height multipliers and low number of steps.
                    Code:
                    float4 texsamp=Tex.SampleGrad(TexSampler,UV+offset,InDDX, InDDY);
                    texsamp*=blendweights;
                    float texatray=max(texsamp.r,texsamp.g);
                    texatray=max(texatray,texsamp.b);
                    texatray=max(texatray,texsamp.a);
                    Quite suitable for terrain.

                    Comment


                      #11
                      Originally posted by Zydila View Post
                      Can you please give a link on it?
                      Eh, missed your post for some reason.
                      Page 95-107
                      The article is about QDM, but the blending part is fully applicable to conventional POM

                      As a side note, it would neat to append several scattered threads like this one into main parallax occlusion mapping thread.
                      Last edited by Deathrey; 11-07-2016, 09:50 AM.

                      Comment


                        #12
                        That page is just talking about using Height Lerp to help make a nicer blend between the layers. It is not a 100% solution. Take a look as the material function "Texture_Bombing_POM" to see a similar example that uses heightlerp to blend between offset samples. You can probably use a similar setup.

                        Your method of using "Max" should actually be pretty similar but that will give a hard edge, whereas using heightlerp should let you control the contrast at the edges. So it will trade some correctness for a softer blend, and can help mix the blend weights nicer.
                        Ryan Brucks
                        Principal Technical Artist, Epic Games

                        Comment


                          #13
                          The gist of the paper I've linked is probably in this phrase:

                          While searching intersection using any
                          online algorithm simply substitute actual h
                          sample by result of blend equation
                          Whole point is doing 1 lookup.
                          In this case POM cost increase for 4 layers, as compared to single layer, constitutes 9 PS arithmetic instructions for each iteration.


                          My reasoning for going with sharp blend instead of height lerp lies in fact that with height lerp between layers, areas where several texture mix, will have an unusual height, that does not correspond to any of the textures. It looks slightly unnatural. Simpe max blend is also cheaper.

                          But yep, there are no issues in using height lerp there instead of MAX.

                          It is not drift free, but at low depth scale it is pretty decent. It is possible to reduce depth at blend regions slightly to further reduce the drift, caused by blend map.




                          I don't know of any realistic way to blend more than two layers seamlessly without mutlipass.
                          Last edited by Deathrey; 11-07-2016, 07:22 PM.

                          Comment


                            #14
                            Right now this is what my setup gives me:




                            Visuals are far from desirable but it is cheap enough to be used on terrain in 4 layer setup.

                            MAX blend, 2 texture fetches per iteration:
                             
                            Spoiler


                            With HeightLerp, 4 fetches per iteration:
                             
                            Spoiler


                            I've tried few optimizations, including doing samples in groups of 4, like Ryan mentioned in his post, but overall performance benefit was quite limited. It actually seemed that benefit of vectorizing stuff was nullified by situations where 3 more samples were taken instead of terminating loop.

                            My next move to do in free time would be to think about a proper way to get vertex colors with offset.
                            Last edited by Deathrey; 11-08-2016, 10:11 PM.

                            Comment


                              #15
                              That last version with height blending is looking pretty good!

                              Are you actually including the blend alpha texture object in your re evaluation of the heights or just using the surface version? it's hard to tell in the video because the camera only pans sideways.

                              The use of 'max' blending in your first examples confuses me a bit since its letting lower height values stomp higher areas which is the opposite of what I'd expect. I guess that means you have pre-height blended the heights -using the height- as well? When I was trying 'max' blending it was basically multiplying Height 1 by alpha and layer 2 by 1-alpha and then using the max as the intersection value and it did not have areas of lower area rendering eroding the higher ones like that method seems to. I will try to get an example soon.

                              One option I considered for this was something kind of like a mini virtual texturing system where you pre-blend and render the heightmaps and can then perform only one texture parallax.
                              Last edited by RyanB; 11-08-2016, 11:41 PM.
                              Ryan Brucks
                              Principal Technical Artist, Epic Games

                              Comment

                              Working...
                              X