Announcement

Collapse
No announcement yet.

Landscape Grayscale (0-256) values filter

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

    Landscape Grayscale (0-256) values filter

    Some people uses Splatmap-RGB to filter values and make the landscape weighmaps.

    I need to use a greyscale map.

    The question is ¿how to correctly filter the grayscale values? For example grayscale from 96 to 128.

    I dont know if there a node to do that. I tried the node BITMASK, asigning a value from 0 to 256, but the result is always black. ¿?

    In other way , ¿what is the correct image type for the grayscale??
    I use image-RGB and take the R channel as greymap... and works.
    But for a image-grayscale, ¿what is the correct format? PNG-8Bits? TGA 8Bits? other? (This is about performance because I need greyscale images of 8196x8196)

    Help & suggestions & properly nodes.

    For the moment this works.
    Click image for larger version

Name:	normalize-grayscale.jpg
Views:	1
Size:	429.6 KB
ID:	1158414

    #2
    Bit mask will only let you extract a single bit from the mask. most likely it worked but the slice it extracted from your gradient was razor thin so you didn't see it.

    If you want to extract a certain range the math is pretty simple.

    Click image for larger version

Name:	GrayscaleRange.JPG
Views:	1
Size:	63.8 KB
ID:	1082695
    Ryan Brucks
    Principal Technical Artist, Epic Games

    Comment


      #3
      Click image for larger version

Name:	grayscale-height-parameters.jpg
Views:	1
Size:	541.1 KB
ID:	1082776
      Works, thanks.
      The problem is when merging the values with a LERP also blends the range filters. It need to use the alpha mask of the LERP to avoid it and separate the mask correctly.
      Now Im using the LANDSCAPE LAYER BLEND node. I created a total of 8 height-layers.
      --------------------------
      WH - White

      RZ - Magenta
      RR - Red

      GY - Yellow
      GG - Green

      BC - Cyan
      BB - Blue

      BA - Black
      -------------------------------

      Click image for larger version

Name:	grayscale-to-layer-blend.jpg
Views:	1
Size:	767.3 KB
ID:	1082778


      The goal is to asign 8 color-textures to each layer with the normals (8x2=16 textures). This is imposible because the MAX texture samplers are 16.
      This is the "wish list":
      ___________________________________
      +1 R Grayscale Height Splatmap OK
      G Grayscale Slopes Splatmap
      B Grayscale Rocks & Others Splatmap
      A Flowmap
      ___________________________________
      *1 RGB Landscape Normal Map OK
      ___________________________________
      *8 Color Maps
      *8 Normal Maps
      ___________________________________
      +2 UE4 Lightmap Cooefficients OK
      +1 UE4 Specular Cubemap OK
      ___________________________________
      5/16 TEXTURES SAMPLERS TOTAL

      For the moment using only the R grayscale splatmap there is a total of 5/16 textures samplers, when should be 4/16 ¿why?
      Another question is ¿how to change the vector R from 1 texture to the B vector of another texture?? Example.
      I created a R color-image extracted from the B normal-image. The goal is to integrate various textures in the same files.

      Comment


        #4

        Now, Im using the node DERIVEFROMZ. (I dont know how to pass the R vector from 1 texture to the B vector to another texture, but the DeriveFromZ seems to solve the problem)
        Using a single texture image I get 2 color texture(B channel) and 2 normal texture.
        In this case with only 4 image files we get 8 color + 8 normal.
        Total:
        5+4= 9/16 TEXTURES SAMPLERS TOTAL

        Is needed some grunge or dirt map textures to aply to the color.
        Another problem is that some images must share the same LandscapeCoords node.

        ¿should be another better way to do it?

        Help & suggestions & properly nodes.

        Comment


          #5
          If you set your samplers to "Shared: Wrap" you can have up to 128 texture samplers.


          I am not sure what the other problem with your blending is or what you used derive normal Z for. The attachment in your last post is invalid. I see what looks like normalize nodes involved in the blending in the previous image but I'm not sure whats going on there.
          Ryan Brucks
          Principal Technical Artist, Epic Games

          Comment


            #6
            Sorry, invalid Attachment file. This is what im trying to do.
            DeriveFromZ:
            Click image for larger version

Name:	DeriveFromZ-to-grayscale-splatmap.jpg
Views:	1
Size:	845.8 KB
ID:	1082793

            Comment


              #7
              Ok I see, you are channel packing two normal maps into one texture. DeriveNormalZ is indeed the correct operation there. It uses the pythagorean theorum to find the remaining vector length.

              It looks like you skipped the biasscale step. When you store normals in a regular non-normalmap texture, the values will be unpacked as 0-1 instead of -1 to 1.

              To fix that, you need to place a "ConstantBiasScale" node for each "Append". Set the "Bias" to -0.5 and the "Scale" to 2.0. Then plug in the result of that to derivenormalZ and you will have a normal map.

              Were you still having problems with the blending as well? I did not quite understand the issue you mentioned with lerp masks carrying over.
              Last edited by RyanB; 07-29-2015, 01:27 PM.
              Ryan Brucks
              Principal Technical Artist, Epic Games

              Comment


                #8
                OK. In the Material>Details>Material Expression Texture Sample... I changed "From texture asset" to "Shared : wrap" and it decreased the number of Texture Samplers; from 9/16 to 6/16 (This, using a grayscale texture + 4 Normal maps).

                ¿Is there any disadvantage or drawback using the "Shared : wrap"(up to 128 textures)?
                I dont know why people refered to "16 Texture Samplers limit" isue. A readed tutorials over internet and all of them uses max 4-5 textures .

                Then, I readed from the next link that is related to OPENGL 16 textures limit max(it refers to mobile games).
                https://answers.unrealengine.com/que...hen-i-add.html
                We are newbies with this engine, but our team is focusing the game to PC/PS4/XOne platforms.

                Were you still having problems with the blending as well?
                Click image for larger version

Name:	lerp-vs-layerblend.jpg
Views:	1
Size:	293.3 KB
ID:	1082990

                I need to filter grayscales and then apply all together linked to the "Base Color". ¡But not blended! For the moment I got it using the node "Landscape Layer Blend"(LB Height Blend).




                I send you the materials *.uasset (remove the .txt extension at end) .
                Attached Files

                Comment


                  #9
                  Hellow again RyanB,
                  after working with your formula i saw that is bad. If we want a grayscale from 96 to 128 it takes the values from 96 to 256. Then we need to subtract. =more compiling shaders time.

                  I discovered a clean way to extract exact grays from images , but not ranges.
                  Click image for larger version

Name:	Dual_Splatmap.png
Views:	1
Size:	566.8 KB
ID:	1103577

                  Here the material itself.
                  Attached Files
                  Last edited by Blackhole Bilbao; 03-31-2016, 11:06 PM.

                  Comment


                    #10
                    The new Quest:
                    extract Brightness values (HS-V) from RGB splatmap image as mask.
                    I created a dual splatmap image.
                    RGB for heights and slopes, and the coverage for foliage and others in the same 3 vectors but with diferent brightness values.
                    ¿How to extract the brightness values as grayscale 0-255??

                    I tried de desaturate node , but has a problem. After remove the saturation, the values also changed. For example a vector R255(B100%) changes to R127(B50%)

                    ¿what is the proper way to do??
                    I tried by multiply before by x3, because GRAY = (R+G+B)/3. = no luck.
                    Also saw a "tedious" node as 3PointLevels¿?
                    I need the mask from the RGB without using the ComponentMask nodes.

                    This is the splatmap for an island in the game.
                    RGBCMYK for heights but also diferent brightness inside for coverages.
                    Click image for larger version

Name:	T_Island_DualSplatmap.png
Views:	1
Size:	912.3 KB
ID:	1103580
                    Last edited by Blackhole Bilbao; 03-31-2016, 10:59 PM.

                    Comment


                      #11
                      Note about my values:

                      In my math, if you extract 96-128, what I would expect to happen is that it starts at 0 at 96 an then reaches 1 at 127 and then stays at 1 until the end.

                      It sounds like what you want is to actually have it switch to black after saturating the 1? fwiw in that case, it doesn't mean what I suggested is wrong, just you want to do something different.

                      Normally the fact that it stays at 1 above the target is not a problem since when you stagger the blends in order, they always draw over the clamped white part.
                      Ryan Brucks
                      Principal Technical Artist, Epic Games

                      Comment


                        #12
                        and then stays at 1 until the end.
                        Yeah, that is the problem we didnt see before. At first sign it seems to work , but with that issue. To remove "1 until end" we need to subtract as I said before. We needed 96 to 128 (maybe grayscaled or white), the rest values black=0.

                        The grayscale filter is not problem. That´s resolved with your first formula, but including that small issue .. "1 until end".

                        The new problem is a new scenario.
                        Extract a mask for only the Brighness values of the image. In photoshop is named HSB (Brightness). In UE4 is named HSV, and goes from 0 to 1.
                        Click image for larger version

Name:	HSV.png
Views:	1
Size:	71.5 KB
ID:	1103595
                        The image of the Island I uploaded before has 2 splatmaps in the same file. We know to extract the diferent channels for RGBCMYK and asing them to landscape_layer_blend(height), but we need also the other values from brightness.
                        Last edited by Blackhole Bilbao; 03-31-2016, 11:05 PM.

                        Comment


                          #13

                          This is the same image as before but removing the saturation in photoshop (saturation -100), in UE4 is desaturate node.
                          Doing this there is another problem, for example, the red R255 changes to R127 with a 50% Brightness, loosing the whole grayscale values from 0-255. Now the values goes from 0 to 127(your first formula doesnt work here).

                          Comment


                            #14
                            Finally got the grayscale values from HS(V). There is a node named RGBtoHSV. In this case:
                            TEXTURE SAMPLE > RGBtoHSV > Mask(B)

                            This is the attachment for previous Invalid Attachment 86381:
                            Click image for larger version

Name:	T_Island_Material_Coveragex.png
Views:	1
Size:	238.3 KB
ID:	1107595

                            Comment


                              #15
                              Another problem when filtering grays is an extrange bordered bevel around the selection. This bevel contains the other grays selections.
                              RyanB, need help with this to finish the landscape material. I dont know if is a bug in UE4.
                              In the splatmap-texture(TGA 24Bits), if I change the filter from "Default" to "NEAREST" is right... the extrange border goes away, but the selection borders are too much jagged.
                              Click image for larger version

Name:	HighresScreenshot00004_Grayscale_Filter.jpg
Views:	1
Size:	747.2 KB
ID:	1107600

                              Comment

                              Working...
                              X