As of May 31, 2023, we have updated our Code of Conduct.
77 votes

Sharp Corners with Signed Distance Fields Fonts

EDIT: Please see my other answer with a concrete solution. I have actually solved this exact problem over a year ago for my master's thesis. In the Valve paper, they show that you can AND two ...
Detheroc's user avatar
  • 1,406
49 votes

Sharp Corners with Signed Distance Fields Fonts

Sorry about the long wait, but it has become obvious that although the article I have promised is basically complete, the publishing process will take some time. Therefore, I have instead prepared an ...
Detheroc's user avatar
  • 1,406
10 votes
Accepted

Is Jump Flood Algorithm Separable?

Quick answers to your individual questions What do you do if your image is not the same size on each axis though? The paper uses square images with side lengths that are a power of 2. This is for ...
trichoplax is on Codidact now's user avatar
8 votes
Accepted

Signed distance field font looks odd

Hmm, that SDF doesn't look right. It should be much smoother, like this image for instance: (image from this blog). One possible issue I noticed in your description: My program first generates a ...
Nathan Reed's user avatar
  • 24.4k
8 votes
Accepted

Asset creation for signed distance field rendering?

Signed distance fields are popular in minimal graphics applications, such as the demo scene, where interesting objects can be synthesized from few simple analytic primitives such as spheres or cubes. ...
Benedikt Bitterli's user avatar
7 votes
Accepted

Sharp Corners with Signed Distance Fields Fonts

Adam Simmons has done some interesting work in this area. I don't know specifically how he's achieving it, but his SDF-based vector rendering is the sharpest I've seen in practice outside of Valve. ...
warrenm's user avatar
  • 386
7 votes

Sharp Corners with Signed Distance Fields Fonts

Quite interesting! I'm the author of the valve signed distance paper. Sorry that it's a little sparse on implementation details. I only included the two channel example as future work - I didn't have ...
chris green's user avatar
6 votes
Accepted

GLSL shapes signed distance field implementation explanation?

Torus A torus is defined by two parameters: the major radius, and the minor radius. The major radius (t.x) is the radius of the big ring (in red in the diagram), ...
Dan Hulme's user avatar
  • 6,650
3 votes
Accepted

MipMaps for Signed Distance Field

When you are making an SDF, you commonly have infinitely detailed data (like, bezier curves making up a letter) that you are making into an SDF image of a specific size. If you make one that is 64x64,...
Alan Wolfe's user avatar
  • 7,711
2 votes

MipMaps for Signed Distance Field

From what I've found, signed distance fields are not suited for minification (drawing the text on fewer pixels on screen than it covers in the texture), no matter how you mip-map them. Their main use ...
Dreamer's user avatar
  • 121
2 votes

Closest sphere on segment

Your actual result is correct in terms of what you can achieve in a single-pass with a fragment shader. It calculates the distance of the fragment's world position to the line segment. That distance ...
Isolin's user avatar
  • 438
2 votes

How can I get a signed distance (SDF) from a mesh?

EDIT I was able to get a simple algorithm working for this purpose, though it's not highly optimized. In my implementation, I use sheer brute force, accelerated by GPU. By this, I mean that I get the ...
Michael Sohnen's user avatar
2 votes
Accepted

Having trouble implementing distance transform with jump flood

I took a few minutes and hacked this to life for you. The bugs were all pretty basic things like using floating point math where it should have been using interger math. All those little fractions add ...
pmw1234's user avatar
  • 2,832
2 votes
Accepted

How to avoid curvature artifact in raytracer?

In raymarching, it's typical to change the direction of the ray according to the fragment coordinates, but leave the origin at vec3(0,0,0). In you code you add r, ...
Michael Sohnen's user avatar
2 votes

3D triangle rasterization to voxels

A brute force method which works well and we use in production code: Calculate AABB of triangle to create a sublist of voxels that may or may not be intersected by the triangle, also calculate the ...
lfgtm's user avatar
  • 391
1 vote

3D triangle rasterization to voxels

A solution could be on the lines of: Consider the side that has the largest extent along some coordinate and draw the Bresenham line along it. Also draw the other two sides and for every voxel of the ...
Yves Daoust's user avatar
1 vote

How to avoid curvature artifact in raytracer?

Some curvature artifacts are normal when doing raymarching or ray-tracing. And if you are careful, you can even find curvature artifacts in some rastered scenes if the triangles are small enough. It ...
Michael Sohnen's user avatar
1 vote

How can I get a signed distance (SDF) from a mesh?

What you want is a Distance Transform algorithm which can be computed very fast using JFA, the steps are basically: Define where you want your seeds (I guess points that make up your mesh. At each ...
Felipe Gutierrez's user avatar
1 vote

How can I get a signed distance (SDF) from a mesh?

Foolproof Accurate Way: Find the nearest element (vertex, edge, or face). Compute distance to it. Check the angle-weighted psuedonormal to tell if inside or out. Brute Force: ...
Andrew Wilson's user avatar
1 vote

How to scale signed distance field fonts properly?

After some trials I've realized my problem was a programming error and not an actual issue with SDF fonts. Originally I was rendering the numbers on the texture of the canvas, which had a fixed scale. ...
Endanke's user avatar
  • 131
1 vote

SDF collision detection

Ive been thinking about the same problem. I suppose rather than finding the level sets, it might be more useful to think of it as finding the local maxima of the sum of the squares of the positive/...
Eelco Hoogendoorn's user avatar
1 vote

Choosing width of data for signed distance field texture

Here are some thoughts: Absolute SDF value clamping, large absolute values of the SDF will not improve the quality of the rendered text. So clamping the values will ensure that you can get higher ...
Mathis's user avatar
  • 119
1 vote

Sharp Corners with Signed Distance Fields Fonts

I am by no means an expert on the subject, but you might be able to, at least in theory, preserve sharp corners in a monochromatic pseudo-SDF if you used either a Bilateral filter a Directional ...
Amaroq Starwind's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible