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

Signed Distance Field Generation

New Here ,
Sep 29, 2023 Sep 29, 2023

Copy link to clipboard

Copied

Hi, what's my best option for producing a higher quality version of the distance node's output? I need something that oversamples the boundary between black and white.

I'm trying to create a signed distance field texture in substance designer from a threshold black and white mask generated from noise. Using the distance node and some blending, I can get something that is pretty close to what I need, but the issue is that the distance node doesn't have the capability to oversample along the boundary between black and white, and thus, it produces pixel artifacts. To illustrate the problem, here are three images.

Black and white mask:

Sean32312180yrjt_0-1696009447378.png
Signed distance field remapped from [-1,1] to [0,1]

Sean32312180yrjt_1-1696009456709.png

SDF visualized by normal

Sean32312180yrjt_2-1696009463911.png

 

In the last image you can clearly see the problem with this approach. The boundary between black and white doesn't contain enough information, and so the distance node produces streaking artifacts. Simply increasing the resolution alleviates the problem somewhat, but it never truly goes away, and working in an unneccessarily high resolution is impractical.

 

 



TOPICS
Substance Graph

Views

313

Translate

Translate

Report

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 ,
Sep 30, 2023 Sep 30, 2023

Copy link to clipboard

Copied

Without seeing your graph, have you tried a small amount of blur HQ ahead of the distance node?

Dave

Votes

Translate

Translate

Report

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
New Here ,
Sep 30, 2023 Sep 30, 2023

Copy link to clipboard

Copied

Hi dave, thank you for the idea. Unfortunately the distance node doesn't take into account any anti aliasing. The documentation says that the distance node measures the distance between any pixel and the nearest pixel above 0.5, and I've verified experimentally. So under the hood it's thresholding the input anyway.

Votes

Translate

Translate

Report

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
New Here ,
Sep 30, 2023 Sep 30, 2023

Copy link to clipboard

Copied

Also, just a minimal reproducible example of the issue: take a threshold black and white texture, connect it to a distance node, connect it to to an invert node and then another distance node. Invert them both. Blend using the subtract blending mode. The result is a signed distance field [-1,1] of the original black and white texture. You can then remap it to [0,1] using a levels node, and then see the boundary artifacts especially when it's connected to a normal node.

Sean32312180yrjt_0-1696089782861.png

 

Votes

Translate

Translate

Report

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 ,
Sep 30, 2023 Sep 30, 2023

Copy link to clipboard

Copied

LATEST

You could try this:

Have a section of your graph working in a higher resolution (I used 8K) and go back to parent resolution after it.

Use a blur HQ grayscale and histogram scan before the distance nodes to smooth out the edges in that higher resolution

2023-09-30_21-06-26.jpg

 

Close up of output without 8K section or Blur HQ or Histogram Scan:

2023-09-30_21-13-51.jpg

Close up of output using 8K section + Blur HQ + Histogram Scan:

2023-09-30_21-13-12.jpg

 

The only other alternative, I can think of, would be to try and write a new Distance node using the pixel processor and loop functions

Votes

Translate

Translate

Report

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