Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Compare neighbouring colors and draw a border line between them?

Community Beginner ,
Feb 06, 2025 Feb 06, 2025

I need to make a following thing in substance designer - let's say I have an image with four areas overlapping each other Red, Purple, Blue and Yellow for example. Is it possible to compare all neighbouring colors in the image and draw a Black border line between Red and Yellow neighbouring colors, and to draw a Green  border line between Blue and Purple colors?

 

Something like this:

Nitroleum_0-1738850475502.png

 

TOPICS
How to
667
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Feb 07, 2025 Feb 07, 2025
Translate
Community Expert ,
Feb 06, 2025 Feb 06, 2025

You could use the pixel processor and write a function to compare neighboring pixels and decide what border colour you want at that pixel. I would use that to output just the borders and then use Shape stroke to expand the borderlines to the width you want them, before blending back with the original image.

Dave

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 06, 2025 Feb 06, 2025

Oh ok, unfortunately I'm not sure how to do it in pixel processor.. Any guides / hints you could share on the setup please?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2025 Feb 06, 2025

Hi,

The pixel processor is a bit of an advanced but very useful node. It looks at each pixel individually in the input image and applies a function, which you create, to that pixel. It then outputs that result at the same pixel location in the output. It then moves on to the next pixel and repeats the same function until all pixels have been processed.

In your use case, you would want the function to examine the neighbouring pixels around the one being processed and decide whether the output should contain a border pixel and of what colour or just be transparent i.e. alpha 0.

 

There is more on the pixel processor here:

https://www.youtube.com/watch?v=5s1p7etqlUw

and here:

https://helpx.adobe.com/substance-3d-designer/substance-compositing-graphs/nodes-reference-for-subst...

Dave

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 07, 2025 Feb 07, 2025

Tanks a lot I will check those vids!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 06, 2025 Feb 06, 2025

Hey Nitrolium,

I made something real quick, it's not tested or optimized, but it does what you need and you can easily edit it.

MarcoVitale_0-1738913113303.png

The node takes 2 colors as input parameters, so you can decide which color you want to separate and a border color, so it does it one by one, to keep everything common and editable.

 

Stay healthy and creative Marco

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 07, 2025 Feb 07, 2025

Oh this looks promising thanks! But for some reason I can't download the file you attached - it is stuck on Virus Scan in progress..

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 07, 2025 Feb 07, 2025
 
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 07, 2025 Feb 07, 2025

Man this is really cool thank you very much! The only thing - how do I then get some individual control over those border lines? For example let's say I want to distort Green and Black border lines with Warp node using different warp intensity settings for those border lines?

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 07, 2025 Feb 07, 2025

And another question if I may - with colors it works perfectly well but when I'm switching to image that is grayscale  it gets a bit unpredictable most probably due to tolerance. So let's say I have a grayscale image with lots of values 30, 56. 255, 0 50 etc. and I need to have a border only between areas that have 33 and 34 in their grayscale values - it's not always precise sometimes affecting neighbouring values.

 

I tried adjusting tolerance but with no much luck, can you please help with that?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 08, 2025 Feb 08, 2025

Can you send me an example image? The Node works for Color images, because that was your initial question and yes it should work for grayscale values as well, since the comparison is basically the same, but for one channel. If your distances between the values are very small, use a 16Bit Texture or even a 32Bit one, to keep precision very high. And use a very low tolerance value.

Send me an example and I see, what I can do.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 08, 2025 Feb 08, 2025

I created this node, so it stores the Lines in the Alpha Channel. So you can use the Alpha Channel as a mask and use it also as an input to drive your warp.

 

MarcoVitale_0-1739002637565.png

Stay healthy and creative Marco

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 08, 2025 Feb 08, 2025

I did a few tests more and it looks like your node works perfectly well! It was actually my texture that had a few off-color areas that was causing issues! I really think you did some amazing work on this node Marco, thank you very much! 

 

Could you recommend some good tuts/course to get the hang of Pixel Processor? Cos majority of those I find on youtube are only touching the base without any advanced stuff which you did here (as far as I understand). 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 08, 2025 Feb 08, 2025

Actually what I did is very basic Pixelprocessor stuff, but I know what you mean, tutorials on the Pixelprocessor are very rare. That's why I'm working on a tutorial series at the moment, unfortunately it's a side project, so i work on it during my freetime, so I have no idea when I'll finish it, but when I do I'll let you know.

Stay healthy and creative Marco

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 10, 2025 Feb 10, 2025
LATEST

This sounds great! I subbed to your gumroad and artstation to stay tuned to your updates!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines