Live data from Hacker News

SDF Fractal Noise

iquilezles.org

41–44 of 44 posts

Re: SDF Fractal Noise

#41

Cool, but this looks like it’s really the same as the old side scrolling mountain landscape screensaver (which I can’t seem to find anymore). Is it just a new technique to achieve the same?

pretty much the whole of Dreams for PS4 is based on SDFs.

here's an image from Dreams: https://cdn.vox-cdn.com/thumbor/dc4ojwiX2EZ3iW8y4oBacZYrIRM=...

This was made using a dual shock controller.

Re: SDF Fractal Noise

#42
post #29

> So, when adding a regular fBM, sine wave or any other displacement function to a "host" SDF, we don't get a valid SDF anymore (we violate the principle that the gradient of an SDF must have length 1.0). Can someone elaborate or point to an elaboration of this point? I guess there must be a good reason why the gradient cannot just be normalised, but I don't know what it is.

After deforming the space with a sine function there is no problem in calculating the gradient. The problem is calculating the new correct distance to the nearest surface after a space transformation. You can see this problem in 2D, here I made an example https://www.shadertoy.com/view/NtsSRf

Re: SDF Fractal Noise

#43
post #29

> So, when adding a regular fBM, sine wave or any other displacement function to a "host" SDF, we don't get a valid SDF anymore (we violate the principle that the gradient of an SDF must have length 1.0). Can someone elaborate or point to an elaboration of this point? I guess there must be a good reason why the gradient cannot just be normalised, but I don't know what it is.

I'm not the greatest at explaining things, but I'll give it a shot.

Just so everyone is on the same page, an SDF is a function that simply returns the distance to the closest surface for any input point. If the distance is positive, the point is outside of the geometry. If the distance is negative, the point is inside the geometry. The gradient of the SDF is calculated by sampling the SDF across multiple points, so the SDF itself doesn't return a gradient.

An SDF is no longer a valid SDF if the distance isn't the true distance to the closest surface. This is usually caused by transforming the SDF non-uniformly, such as adding a sine wave. Another way to think about this is that a valid SDF is in euclidean space while an invalid SDF is in non-euclidean space. Applying a displacement function will compress and stretch space non-uniformly.

Imagine you have an SDF function that just represents a sphere. Then you transform the vertical position of the sphere based on the absolute value of the horizontal position of the input point. This will turn the sphere into a V shape. However, the SDF is no longer a valid SDF. If you sampled a point next to one of the inner walls of the V shape, it wouldn't return the distance to the wall, it would return the distance to the point on the shape below it.

The gradient for every possible point in a valid SDF will be a unit vector because space is uniform. A non-valid SDF will contain non-unit-vector gradients between areas of non-uniformity.

Hopefully that made sense. If you are still confused, I would suggest writing a simple raymarcher on Shadertoy and playing around with distorting SDFs yourself. A simple raymarcher is only a couple lines of code (probably less than 20 lines of GLSL).

Re: SDF Fractal Noise

#44
post #16

SDFs are another tool. Very useful for content creation, for example, although there are still very few tools to create SDFs. You can't create SDFs in Blender for example. SDFs will be more used in the future, polygons are a mess... :) Games like Dreams (PS4 / PS5) make extensive use of SDFs

[deleted]
Post reply on HN