I am trying to extrack different color intensity in a texture.
For exemple:
I output de Red channel of a texture where there are 3 value of red, 1, 0.5 and 0.25.
I would like to be able to take each of them seperatly so that I can apply a different color for each.
I know that using the substract math function can help me get the intensity of 1 but I can’t seem to figure out how to only get the 0.5 and the 0.25.
Would anyone know of a way to seperate them all?
Thanks in advance for the help I really appreciated it!
There are Artifacts with the IF method, as you can see in the earlier screenshots, so I’m still working on it. If I decrease the threshold, the artifacts start to vanish for the far ends but the quality of the goal start is get pretty rough.
See the much lower threshold below for the 0.5
You would have to use an uncompressed texture and not use mipmaps if you want to avoid artifacts like that, but performance wise you would be better off using 2 compressed textures instead of trying to clamp out different intensities.
The use of that is that every channel RGB would have a motif and each motif would have these intensity. Each intensity would have a color so that I can create multiple motif with different color without having to load more texture. If basically for more variaty.
I just tried what posted but I dont get the same result at all. When I try the 0.25 value I only see the 0.5 an when I try the 0.5 value they all get black. I tried the two threshold value of 0.1 and 0.01 but still no luck in getting the same result.
Using textures like that will lead multiple problems. You need to disable compression, srgb, texture filtering and mipmaps. Also you need more complex material to extract those 1-bit patterns from your textures. So you are throwing all the build in hardware performance optimizations for small to non existant memory savings.
Honestly I would encode a fattened alpha or just surround each text block in an alpha color rectangle. Then by multiplying the alpha mask result with the emissive font mask and it should hide the artifact since they will not line up with any edges in the font.
Well the alpha could maybe work with my image right now, but that image was just for testing. So I could have ovelay of intensity inside the material. My main goal is to have a motif in each channel and since each motif will not have the same look then they can’t use the same alpha.
ah I see, yes my idea only works if the elements do not overlap on top of eachother. If you are going to have them spaced apart then it should work fine. but the fact that you are not channel packing seems to me to indicate they cannot overlap anyways.
This is probably excessive in your case but you could solve it with manual texture filtering. Somebody mentioned disabling texture filtering and that is probably the best option. You can write your own manual texture filtering. But then you will be in a weird place where you can’t really get nice aniso mips since you will have to do it manually. if its just for a UI element its not a big deal. You may be able to find some guides on manual texture filtering. a tutorial on that is a bit too lengthy to come up with on the spot though.
either that or you simply use a different channel for each mask. that solves it entirely but then you only get 4 elements per texture. if you channel pack you dont have the luminosity problem since the channels are independent (except for some leaking compression artifacts, go uncompressed if it matters).
I find it strange that the Clamp does not do what I am trying to achieve since the clamp only let a value pass if it’s between the min and max value. I am not sure what you mean by manual texturing filtering. I dont know if that needs programming, I am not a programmer
I am sure there is a math way of achieving of only getting one intensity out of the red channel.
Maybe the problem is in my image.
Here are my red color values in photoshop (black and white layer in a group with only red channel activated):
1 = 255,255,255 (RGB)
0.5 = 128,128,128 (RGB)
0.25 = 64,64,64 (RGB)
When textures get compressed and processed by any game engine, you’re going to lose your perfectly clean values. Because they get compressed which adds compression artifacts and values outside of 1 .5 and .25. Also when a texture gets further away, the game engine wants to switch to a lower resolution version of the texture, which blurs the texture and dirties those values even more. You can disable those features by finding the right options and check boxes, but this approach in general is not optimal and there’s probably other ways of achieving what you want to do in the end.
I am not sure what you mean about clamp not doing what you are trying to achieve. It does exactly what it says it should do. It doesn’t select a range, it clamps the output to be within the specified min/max.
If you have a black pixel next to a white pixel, when texture filtering is applied that means you actually have a gradient going from 0 to 1.0 that happens across the width of 1 pixel. So the borders of your white pixels have all other values surrounding them automatically. So that edge contains your 0.25 as well as your 0.5 value. The only way to disable that is to disable texture filtering which means your pixels will be hard squares.
Manual filtering doesn’t require programming but does require advanced material usage. I don’t want to go through the crazy long steps to suggest how to do it when you haven’t replied to my other much easier suggestions like channel packing.
To disable texture filtering you go into the texture properties in UE4 and change it from “default” to “Nearest”.
You did not respond on my channel packing suggestion. Is there some reason you have to do it this way rather than using a different color channel for each image? Again I do not see the point in using color textures that have all grey values and not leverage channel packing which solves all your problems. The only limitation would be 4 stamps per texture.
“I am sure there is a math way of achieving of only getting one intensity out of the red channel.”
Yes but with texture filtering, ALL the values are actually there, just in a small border.
Here is an example of why this happens. Lets say you have a 2x1 mask that has one white and one black pixel. With nearest filtering (aka filtering disabled) it would look like this zoomed in:
But once texture filtering is applied, it is actually this you will get:
So if you were to try to extract a mask for say 0.5… it would show up here because the value exists. It would show up as a thin aliasing line right in the center here. But if you did it without filtering, the value wouldn’t exist.
What you have is the above situation surrounding all your font edges.
The reason I dont want the 4 colors to be one in the Red channel, one in the green, one in the blue and one in the alpha, is that each channel would have it’s own motif inside.
I would only use one channel or mix the result of 2 to get more variations without having to load more texture. This technique qould be very useful for furniture, wallpaper and clothing motif on them.
Ex:
Red channel = Horizontal lines
Green channel = Vertical lines
Blue channel = Dots (Tiling)
Alpha channel = Opacity
I can’t seem to view you 2 attachents. It say’s ‘‘Invalid Attachment specified. If you followed a valid link, please notify the administrator’’
Here is another idea and probably how I would approach this.
Use more of a distance field approach. You can just blur your hard edges for now but you can use the photoshop layer style->stroke->gradient->shape burst method for nicer results.
This method relies on the fact that you have gradients that are discrete for each layer, and separated by common border colors. Here there is a constant 0.5 separating the two fonts, and one is brighter one is darker. Made by simply duplicating the same layer and making one lighten and the other inverted and set darken. You could easily mask for either shape and get a nice soft mask.
You could extend it to have more than 2 things obviously but you will have to expand the area around the additional shapes with a color that is inbetween them. This will work for any number of blends but at some point you will lose precision as there are only 256 values in an 8 bit texture.
What this really does is create a discrete field around each shape, whereas in your original image, all shapes blend with 0 which means and blend with 1 is guaranteed to capture all values in between which gives the aliased edges.
But wouldn;t it be simpler to subtract 0.25, then clamp 0-1, then add 0.25 to get the 0.5 and 1.0 left alone then do the same for 0.5 to get just 1.0 on its own. You can do it the other way around as well and do some min/max tricks to isolate the one you want.
Here is how I extract a gradient of a certain width from an edge like that. Lets call the texture sample red channel Tex.R.
clamp ( abs(Tex.R - Location) / Width )
By default this would make a mask that is black at Location and white after distance of ‘width’. If you want the opposite, then you can do 1-x and it will be a white mask at Location. Or if you use it as a lerp mask skip the 1-x and just flip the A/B.
I come from the following link with the same problem, in that case for a landscape, not for forniture.
If helps , some weeks ago I tried playing with ConstantBiasScale] in combination with the nodes ceil] and floor] but finally abandoned the idea because always finished with a dead-end.