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.

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.

1f3b87f81008e725b8e065867decf08ed3ae10b5.jpeg

d0152d3b0a0dbcf48beb21c09f313d7e75cb8d2b.jpeg
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

3e537cbdfde4c578346825231d8903cb11108f05.jpeg

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.

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.

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.

Sorry, invalid Attachment file. This is what im trying to do.
DeriveFromZ:
962957a83e7d548b3647abdede4a0bd54ff89ede.jpeg

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.

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).

We are newbies with this engine, but our team is focusing the game to PC/PS4/XOne platforms.

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) .

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.

Here the material itself.

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.

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.

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.
HSV.png
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.

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).

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:

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.

zoomed:

Seems to be a problem with the DXT5 compression and texture filter. Only works with the texture filter in “Nearest”

From documentation:
… the SimpleAverage setting uses a 2x2 kernel size, and all Sharpen settings use a 8x8 kernel and some negative weights to sharpen. Sharpen0 is not sharpening, but it still uses the quality down-sampling filter all Sharpen settings use (4x4 Gaussian kernel). Compared to SimpleAverage, it appears blurrier but higher quality.

Mip Gen Settings This option allows you to customize how the content of the mip-map chain looks. Note that the usage of mip-maps can reduce Texture details. In order to counteract the blurring the mip-mapping introduces, it is possible to sharpen the image during down-sampling to restore some of the information loss. Using a limited amount of sharpening (values up to 4 or 5) can help to increase the image quality without performance loss or memory cost. Using strong sharpening (values bigger than 6) can result in dark or bright borders around the image content, but this might be acceptable in certain situations (depending of art style and Texture content).

When you are using color content, the sharpening is not processing the color channels independently. Then luminance is done as defined and the chrominance (color) information is down-sampled without sharpening (currently 2x2 but 4x4 Gaussian would be possible as well). This avoids a color shift in some extreme cases. Sharpening also helps to improve the DXT compressor as the compression of subtle color shades is limited.

Brightness Curve Modifies the brightness of the Texture using a curve. Each pixel has its HSV Value component raised to the power specified. This scales the image brightness non-linearly using a curve defined by the power function. Values less than 1.0 increase the brightness of the image, while values greater than 1.0 decrease the image brightness. You can enter whatever number you want, but the final V value will be clamped between 0.0 and 1.0 (per pixel.) The default for this setting is 1.0.

**Chroma Key Texture ** If true, the chroma key image, replacing any pixels that match Chroma Key Color with transparent black.

I tried diferent ways with no luck:

…\Epic Games\4.10\Engine\Source\Runtime\Engine\Classes\Engine\TextureDefines.h
TEXTUREGROUP_Splatmap UMETA(DisplayName=“Splatmap”),

…\Documents\Unreal Projects$$$\Config\DefaultEngine.ini
TEXTUREGROUP_Splatmap=(MinLODSize=1,MaxLODSize=16384,LODBias=0,MinMagFilter=aniso,MipFilter=point,MipGenSettings=TMGS_Sharpen6)

Changed from “Shared:warp” to “From Texture Group”

Changed the texture group to “UI group”

Reinported the texture (as bmp, tga, png…) unchecked defercompression and save without altering any compression settings. Also TC_HDR with no Compression.


*Above,texture filter “Normal” V.S “Nearest” *

When filtering a grayscale range also takes the values of that gray border. Then, the masks appear beveled with the “Normal” filter, or jagged with the “nearest” filter.
I also need the RGB colors from texture without the nesrest filter.

¿nobody?

What you are seeing is not any kind of bug. Texture filtering by definition blends each pixel with its neighbors. You are using the grayscale values as a color ramp so anytime you blend a white pixel with a black pixel you will have all grey values in between present on the edge of that texture, and thus you also have a 1-texel wide slice of your whole color ramp displayed across that border.

See this thread for some possible ideas for solving this that don’t involve hard edges:
https://forums.unrealengine.com/showthread.php?108795-Extrude-Texture-intensity-in-Different-masks

Yes, that link is the same scenerio like this.

The grayscale filter would be interesting in order to add layers like water in rainy days, snow in winter or flowers in spring…
With that jaggied borders the only utility may be for the procedural foliage (hidden masks+filter nearest).

My goal was to use 1 RGBCMYK for the base and up to 128 grayscale layers over, masked them for aditions like wearmaps, flowmaps, snow, erosion, deposits etc.
If I dont find a solution the only way will be using 2 x RGBCMYK splatmaps for a total of 14 layers.