POV-Ray : Newsgroups : povray.unofficial.patches : bicubic interpolation patch : Re: bicubic interpolation patch Server Time
28 Sep 2024 16:49:34 EDT (-0400)
  Re: bicubic interpolation patch  
From: Warp
Date: 11 Jun 2003 06:15:33
Message: <3ee70145@news.povray.org>
While we are at it, how about implementing some kind of trilinear and
tricubic mapping?
  Naturally the only problem to solve is what mipmap to use for reflected
and refracted rays (for direct camera rays it is trivial, as the formula
to choose the mipmap is the same as with scanline rendering). Perhaps the
total length of the rays traced so far for the current pixel could be a
good heuristic...

  For those who don't know what trilinear/tricubic mapping is, here's an
explanation:

  Bilinear/bicubic mapping helps smoothing pixelation when image map
samples are needed from between the image map pixels. This is done by
interpolating between the 4/16 pixels around the point we want the color
from.
  However, this works ok only when the image map pixels are larger than
the rendered image pixels. When the image map pixels are smaller,
bilinear/bicubic mapping doesn't help: You get moire artifacts.

  Mipmapping is a technique to avoid these moire artifacts.
  It's idea is that smaller versions of the original image map are calculated
by averaging pixels (the first mipmap is 1/4 of the size of the original, the
second mipmap is 1/4 of the size of the first mipmap and so on). When a
sample of the image map is needed, it's taken from the largest mipmap which
pixels are larger or equal to the rendered image pixels (there's a simple
formula to calculate this). Bilinear/bicubic interpolation is used normally
on this mipmap (or the original image if its pixels are large enough). This
gets completely rid of the moire effects.

  But mipmapping alone is not enough. If you use mipmapping only, you will
get clearly visible lines in the texture where there's a change in mipmap.
This can be even worse than the moire effects.
  To solve this, we don't take just one mipmap, but we also take the next
mipmap smaller than the chosen one, take the sample from it as well, and
then interpolate between these two samples (linear interpolation is sufficient
in this case). The "distance" between mipmaps can be calculated with the
same formula as the one mentioned above to choose which mipmap to use.

  This is called trilinear or tricubic mapping (depending on whether we are
using bilinear or bicubic sampling) and results in a completely smooth
texturing with no moire effects nor pixelation.

  (However, to be frank, the paragraph above is untrue: If you look at the
textured surface from a very small angle, you can still get moire effects,
but this is caused by a slightly different reason. There's a solution for
this problem as well: anisotropic filtering. However, this filtering may
be quite complicated to implement (I don't really know how it works). OTOH
this artifact is seldom a real problem.)

-- 
#macro M(A,N,D,L)plane{-z,-9pigment{mandel L*9translate N color_map{[0rgb x]
[1rgb 9]}scale<D,D*3D>*1e3}rotate y*A*8}#end M(-3<1.206434.28623>70,7)M(
-1<.7438.1795>1,20)M(1<.77595.13699>30,20)M(3<.75923.07145>80,99)// - Warp -


Post a reply to this message

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