Clamp Greyscale Texture Min / Max
-
jake.carvey
- Posts: 16
- Joined: Thu Feb 22, 2018 9:39 pm
Clamp Greyscale Texture Min / Max
I need to do something similar to the Min/Max/Clamp UV example in the tutorials:
https://www.youtube.com/watch?v=R0yyoqgpdg8&t=29s
But I need it to work on a greyscale image channel, and clamp doesn't work with texture samplers:
Desired result: extract ONLY the number "2', and remap it to black & white
very grateful for any help
- jake
https://www.youtube.com/watch?v=R0yyoqgpdg8&t=29s
But I need it to work on a greyscale image channel, and clamp doesn't work with texture samplers:
Desired result: extract ONLY the number "2', and remap it to black & white
very grateful for any help
- jake
- Ricardo Teixeira
- Posts: 954
- Joined: Fri Aug 09, 2013 2:26 pm
Re: Clamp Greyscale Texture Min / Max
Hello Jake,
Thanks for getting in touch, we would be happy to help.
The Clamp node does work but, unfortunately, not for the specific effect that you intend to build. To a certain extent, extracting specific values from a texture is possible but, depending on the complexity of your texture, it requires a considerable amount of work.
Have you considered using an alternative masking system such as an atlas based on the included sample? (ReadFromAtlas sample)
I took the liberty of building a simple example using the functionality you were looking for.

Check the attached Unity Package.
Thanks!
Thanks for getting in touch, we would be happy to help.
The Clamp node does work but, unfortunately, not for the specific effect that you intend to build. To a certain extent, extracting specific values from a texture is possible but, depending on the complexity of your texture, it requires a considerable amount of work.
Have you considered using an alternative masking system such as an atlas based on the included sample? (ReadFromAtlas sample)
I took the liberty of building a simple example using the functionality you were looking for.

Check the attached Unity Package.
Thanks!
- Attachments
-
- TextSample.unitypackage
- (16.82 KiB) Downloaded 1247 times
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
jake.carvey
- Posts: 16
- Joined: Thu Feb 22, 2018 9:39 pm
Re: Clamp Greyscale Texture Min / Max
Let me be a bit more specific. We are looking to use a single texture channel, to create approx.16 individual masks. In order do so, we need to clip any value above, say, [ 0.54 ] brightness to black, and then, clip any value below [ 0.50 ] brightness to black (the rest is fairly simple).
ReadFromAtlasd doesn't seem like it will work for our purposes - the entire point is that each mask stays in it's exact UV position, and all other masks are overwritten with black, as the intention is to mask a specific piece of UV mapped geometry.
The system works very with specific texture maps, but it just requires many separate maps which is just grossly inefficient, and we are already running out of texture memory.
I look forward to more ideas! It is so very close, I can almost taste it!
cheers
jake
ReadFromAtlasd doesn't seem like it will work for our purposes - the entire point is that each mask stays in it's exact UV position, and all other masks are overwritten with black, as the intention is to mask a specific piece of UV mapped geometry.
The system works very with specific texture maps, but it just requires many separate maps which is just grossly inefficient, and we are already running out of texture memory.
I look forward to more ideas! It is so very close, I can almost taste it!
cheers
jake
- Ricardo Teixeira
- Posts: 954
- Joined: Fri Aug 09, 2013 2:26 pm
Re: Clamp Greyscale Texture Min / Max
I understand what you are trying to build but, unless you have a specific technique in mind, it's going to become a bit "complex" to extract/clamp 16 mask from a single texture.jake.carvey wrote:Let me be a bit more specific. We are looking to use a single texture channel, to create approx.16 individual masks. In order do so, we need to clip any value above, say, [ 0.54 ] brightness to black, and then, clip any value below [ 0.50 ] brightness to black (the rest is fairly simple).
ReadFromAtlasd doesn't seem like it will work for our purposes - the entire point is that each mask stays in it's exact UV position, and all other masks are overwritten with black, as the intention is to mask a specific piece of UV mapped geometry.
The system works very with specific texture maps, but it just requires many separate maps which is just grossly inefficient, and we are already running out of texture memory.
I look forward to more ideas! It is so very close, I can almost taste it!
cheers
jake
Check the sample attached, do take into account that texture filtering will influence the results, you will have to account for it. I made it B&W using different nodes as an example, it really depends on your specific use.
Have you considered using a Texture Array? ASE includes a sample and tool to build them.
With a few adjustments/remapping, the Atlas method could work well; in any case, it really depends on how you intend to use it.
Thanks!
- Attachments
-
- Text2.unitypackage
- (14.23 KiB) Downloaded 1299 times
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
jake.carvey
- Posts: 16
- Joined: Thu Feb 22, 2018 9:39 pm
Re: Clamp Greyscale Texture Min / Max
I have made progress using CLAMP for the UV coordinates - although it is not ideal, as I have to create an individual texture sample for each extracted mask (with a max of 16 ( minus a few for albedo and normal ).
Here is a quick screengrab of the network. I would love to just be able to just draw rectangles of white or black over the top, bottom, left and right, to block the unwanted areas. That would save a ton of texture samplers, and be very easy to adjust. Maybe with overlaid gradients somehow?
Thank you for that second example - I was able to arrive at something similar, but still not able to eliminate both above and below the threshold. I will keep trying.
jake
Here is a quick screengrab of the network. I would love to just be able to just draw rectangles of white or black over the top, bottom, left and right, to block the unwanted areas. That would save a ton of texture samplers, and be very easy to adjust. Maybe with overlaid gradients somehow?
Thank you for that second example - I was able to arrive at something similar, but still not able to eliminate both above and below the threshold. I will keep trying.
jake
-
jake.carvey
- Posts: 16
- Joined: Thu Feb 22, 2018 9:39 pm
Re: Clamp Greyscale Texture Min / Max
Ok - the last sample is giving me a couple of new ideas how to approach it - thank you.
jake
jake
- Ricardo Teixeira
- Posts: 954
- Joined: Fri Aug 09, 2013 2:26 pm
Re: Clamp Greyscale Texture Min / Max
That amount of Texture Samples is not recommended for that specific purpose.
Adjusting UV coordinates would be ideal but, alternatively, you can also try to mask it as shown in the sample shared.
Looking forward to see what you build!
Adjusting UV coordinates would be ideal but, alternatively, you can also try to mask it as shown in the sample shared.
Looking forward to see what you build!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
Lars Nonne
- Posts: 18
- Joined: Mon Feb 12, 2018 4:54 pm
Re: Clamp Greyscale Texture Min / Max
Hi,
I|m not entirely sure, what you are trying to achieve, since you could simply use the same texture multiple times.
Either to that in the shader or, in some cases you might need to enable gpu instancing.
Anyways. I added a small shader. Since I'm not certain what you are trying to do, this might or might not help.
Lars
I|m not entirely sure, what you are trying to achieve, since you could simply use the same texture multiple times.
Either to that in the shader or, in some cases you might need to enable gpu instancing.
Anyways. I added a small shader. Since I'm not certain what you are trying to do, this might or might not help.
Lars
- Ricardo Teixeira
- Posts: 954
- Joined: Fri Aug 09, 2013 2:26 pm
Re: Clamp Greyscale Texture Min / Max
Hello Lars,Lars Nonne wrote:Hi,
I|m not entirely sure, what you are trying to achieve, since you could simply use the same texture multiple times.
Either to that in the shader or, in some cases you might need to enable gpu instancing.
Anyways. I added a small shader. Since I'm not certain what you are trying to do, this might or might not help.
Lars
Thank you for helping out!
I think the UV option would be the best option for his current requirements.
Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
-
jake.carvey
- Posts: 16
- Joined: Thu Feb 22, 2018 9:39 pm
Re: Clamp Greyscale Texture Min / Max
Lars,
Thanks - I will check yours out as well!
Already tried the separate image mask strategy, but we need more than 16 masks per shader.
The issue is with the UV's, I couldn't find a way adjust the UV coordinates of a texture that's shared through a Local Var. Each separated UV "section" requires a unique Texture Sample?
Luckily Ricardo's last shader example put me on the right path - I will have the new shader built tonight and will share it here!!! it has a few unique requirements, but I can live with that.
thanks!
Thanks - I will check yours out as well!
Already tried the separate image mask strategy, but we need more than 16 masks per shader.
The issue is with the UV's, I couldn't find a way adjust the UV coordinates of a texture that's shared through a Local Var. Each separated UV "section" requires a unique Texture Sample?
Luckily Ricardo's last shader example put me on the right path - I will have the new shader built tonight and will share it here!!! it has a few unique requirements, but I can live with that.
thanks!