POV-Ray : Newsgroups : povray.bugreports : Mach artifacts in blob objects : Mach artifacts in blob objects Server Time
13 May 2024 22:36:16 EDT (-0400)
  Mach artifacts in blob objects  
From: Jorge Stolfi
Date: 25 Nov 2009 23:55:01
Message: <web.4b0e095d31baac1245826d470@news.povray.org>
Hi, there is a bug (or "surprising feature", if you will 8-) in the
formula thatPOV-Ray uses for blob objects.

Consider a spherical blob component "sphere{ C, R, S }". According to
the reference manual, its density function at distance "d" from the
center "C" is "F(d) = (1 - (d/R)^2)^2"

By this formula, the second derivative of the density "F(d)" with
respect to "d" does not tend to zero when "d" tends to "R" from below.
This means that the blob's surface is continuous only to the first
order; its curvature changes abruptly as one enters or leaves the
sphere of influence of each component.

Those discontinuities turn out to be far more visible than one might
think. If the object has Lambertian finish, the discontinuities make
the seam between adjacent blob elements look distinctively brighter
than the elements, as in the picture below (left):

  http://www.ic.unicamp.br/~stolfi/misc/2009-11-pov-blob-bug/fig_00.png

This is an optical illusion, closely related to the "Mach bands" effect.

If the blob has mirror finish, the 2nd order discontinuities in the
surface create 1st order discontinuities ("kinks") in the the
reflected images of straight lines, as shown here (left):

  http://www.ic.unicamp.br/~stolfi/misc/2009-11-pov-blob-bug/fig_01.png

In both images, the object on the left is a blob with two spherical
elements (radius of influence 1.80, center-to-center distance 2.00,
threshold 0.093364). The one on the right is a CSG imitation, where
the seam is a piece of a "torus" surface, computed to give 1st order
surface continuity and approximately the same curvature as the blob's
seam.

These Mach artifacts are apparent even in small blobs. They make the
seams stand out, even on objects that are supposed to be smooth.

The only way to avoid the discontinuities is to increase the element
radii and adjust the threshold so that the entire surface of the blob
lies within the sphere of influence of all its elements. But then the
elements lose their identity, and the user loses control of the shape.

While this is technically a "feature" rather than a "bug", it severely
limits the usefulness of the "blob" primitive. One can fix this
problem by replacing the density formula "S*(1 - (d/R)^2)^2" by the
new formula "S*(1 - (d/R)^2)^N" where N is 3 or more. This function is
continuous to (N-1)th order everywhere.

The following pictures compare the seam produced by the current blob
formula (left) and by this "supersmooth blob" formula with N = 4
(right):

  http://www.ic.unicamp.br/~stolfi/misc/2009-11-pov-blob-bug/fig_10.png
  http://www.ic.unicamp.br/~stolfi/misc/2009-11-pov-blob-bug/fig_11.png

Note that the new formula yields a visually smooth joint under
Lambertian shading, and removes the kinks from the reflected stripes.

Of course, simply changing N in the formula will shift the blob's
surface inwards and hence break old POV sources. For example, in order
to obtain an N=4 superblob with approximately the same size shape as
the ordinary blob, it was necessary to set the influence radius R to
2.1 (instead of 1.8) and lower the threshold to 0.057552 (instead of
0.093364). To implement this fix in a back-compatibile way,
one could add to the blob primitive an optional parameter
"order N", defaulting to "order 2".

Of course, one can already obtain these "supersmooth blobs" through
the "isosurface" primitive (as I did in the last two images above).
However, the isosurface primitive uses a generic root finder that is
much slower than the blob's specialized root finder. Also, the
isosurface primitive lacks the blob's internal element-bounding hierarchy,
hence it must evealuate all terms of the function, for every probe
along every ray. Thus, for example, the images with the
supersmooth blobs above took about 100 times longer to render
than the images with ordinary or CSG-faked blobs.  Clearly, "isosurface"
is not a viable alternative to built-in supersmooth blobs.

Hope it helps. All the best,

--stolfi

PS. The POVRAY sources for those images are in

  http://www.ic.unicamp.br/~stolfi/misc/2009-11-pov-blob-bug/sources.tgz

The camera settings assume 8:3 image aspect ratio.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.