Clamp Greyscale Texture Min / Max

Node-based Shader Editor

Re: Clamp Greyscale Texture Min / Max

Postby Ricardo Teixeira » Sun Feb 25, 2018 3:54 pm

jake.carvey wrote: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!


Looking forward to the final result!

You actually sample once and use other Texture Sample nodes as references.

Image

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!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Clamp Greyscale Texture Min / Max

Postby jake.carvey » Mon Feb 26, 2018 7:23 pm

Here is my in-progress solution. Our shader is quite a bit more complex than this - it uses an array of these masks to allow another set of custom damages textures to "bleed" through (clipped by these masks first). Those damage textures in turn will soon use texture arrays to randomize the damage textures.

1. If using for Transparent Cutout / Clip Mapped Alphas( like we are ), then the textures should have no anti-aliasing, no smoothed edges, as they will become artifacts (use threshold filter, pen tool, etc. to ensure jagged edges

2. If using for Transparent Cutout Alphas, be sure to use nearest neighbor / point filtering (?), and turn off mipmaps, or create manual mipmaps to prevent artifacts

3. Use Lower Clip and Upper Clip sliders in the material parameters to define which (greyscale) range to extract from the image channel

Will post more progress later - hopefully this helps. I will cross-post on that massive, somewhat chaotic Unity3d.com forum as well ( I personally like this one better, because the topics are organized and searchable.)

thanks for all the help so far - we love the way the Amplify Shader Editor has unfolded.

- jake

Clip 12345.unitypackage
(103.87 KiB) Downloaded 104 times
jake.carvey
 
Posts: 16
Joined: Thu Feb 22, 2018 9:39 pm

Re: Clamp Greyscale Texture Min / Max

Postby jake.carvey » Mon Feb 26, 2018 7:26 pm

Also - very good to know about the Texture Sample Referencing. I was trying to force the Local Var to be something it wasn't - feeling much more confident now!!

jake
jake.carvey
 
Posts: 16
Joined: Thu Feb 22, 2018 9:39 pm

Re: Clamp Greyscale Texture Min / Max

Postby jake.carvey » Tue Feb 27, 2018 6:34 pm

Getting closer to the end result. This is one of 16 or so node groups that get multiple together to create Transparent Cutout (as well as some color around the edges of the hole.)

Any suggestions very welcome in terms of optimization, etc. Will continue to share progress. Everything here is in the interest of really streamlining workflow and preventing too much "thinking" for the texture and modeling staff (which right now, is, me).

Capture.JPG
Capture.JPG (184.45 KiB) Viewed 1632 times
jake.carvey
 
Posts: 16
Joined: Thu Feb 22, 2018 9:39 pm

Re: Clamp Greyscale Texture Min / Max

Postby sazberryftw » Wed Feb 28, 2018 9:36 am

Hey! After looking through the examples here I achieved a solution that works for me. :)

I am using a greyscale texture mask with 6 different RGB values on it (0, 51, 102, 153, 204, 255). I want to grab each of these values and turn it into it's own B/W mask, where white is that value and black is everything else. I then use these masks individually to set a colour to each area.

Download link (was slightly too big for direct upload here): https://drive.google.com/open?id=1jAHy0 ... b-aSkPlcZv

My shader works by first grabbing everything of RGB value 0 and under and masks that out. I then increase my range for the next step, and subtract the previous mask to get my next mask.

Image

A few things to note with my shader if you use your own texture:
- Shader uses the red channel of the texture
- Texture must be linear (disable sRGB in import settings)
- UV islands must have enough padding to avoid artifacts

I intend on using this technique along with other standard elements (metallic, roughness, detail maps etc) for my final shader which I might post in a separate thread once I've done. I've also moved the steps into a shader function to tidy up the layout, but I left it without it for my example so the flow is more clear.

Example using shader function

Image

If anyone has any tips for different/better ways I could do this let me know. And I hope this might be helpful for anyone trying to achieve the same result. :)
sazberryftw
 
Posts: 27
Joined: Wed Aug 23, 2017 1:38 pm

Re: Clamp Greyscale Texture Min / Max

Postby Ricardo Teixeira » Wed Feb 28, 2018 11:25 am

Very nice results, thank you for sharing!

We would be happy to share it with the community if you are interested, fully credited of course.

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!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Clamp Greyscale Texture Min / Max

Postby sazberryftw » Wed Feb 28, 2018 12:16 pm

Ricardo Teixeira wrote:Very nice results, thank you for sharing!

We would be happy to share it with the community if you are interested, fully credited of course.

Thanks!


Sure! I will put together a nice clear version and send it over. Is there an preferred way of demonstrating it in the scene? I know most examples are done on the Shader Ball, but is it fine to demonstrate on a unique mesh?
sazberryftw
 
Posts: 27
Joined: Wed Aug 23, 2017 1:38 pm

Re: Clamp Greyscale Texture Min / Max

Postby Ricardo Teixeira » Wed Feb 28, 2018 12:42 pm

sazberryftw wrote:
Ricardo Teixeira wrote:Very nice results, thank you for sharing!

We would be happy to share it with the community if you are interested, fully credited of course.

Thanks!


Sure! I will put together a nice clear version and send it over. Is there an preferred way of demonstrating it in the scene? I know most examples are done on the Shader Ball, but is it fine to demonstrate on a unique mesh?


Awesome, looking forward to it!

No worries, we adjust/tweak and build the actual demo scene; a simple example would be a great starting point.

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!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Clamp Greyscale Texture Min / Max

Postby jake.carvey » Wed Feb 28, 2018 6:07 pm

Ah - this makes my heart beat faster. Nice work.

Should finish our master shader tomorrow - some other priorities we had to deal wiht in the meantime.

jake
jake.carvey
 
Posts: 16
Joined: Thu Feb 22, 2018 9:39 pm

Re: Clamp Greyscale Texture Min / Max

Postby sazberryftw » Mon Mar 05, 2018 9:09 am

jake.carvey wrote:Ah - this makes my heart beat faster. Nice work.

Should finish our master shader tomorrow - some other priorities we had to deal wiht in the meantime.

jake


Thanks! Sounds good :)
sazberryftw
 
Posts: 27
Joined: Wed Aug 23, 2017 1:38 pm

PreviousNext

Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 0 guests