POV-Ray : Newsgroups : povray.beta-test : Height field defects Server Time
29 Jul 2024 10:24:11 EDT (-0400)
  Height field defects (Message 11 to 11 of 11)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Slime
Subject: Re: Height field defects
Date: 1 Feb 2004 17:33:14
Message: <401d7eaa$1@news.povray.org>
>   Does anyone know what's going on here?


Well, the fundamental difference between height field smoothing and mesh
smoothing is that height field smoothing is done per-square and not
per-triangle. That may be the sole reason for the visibility of the squares.
That, plus the fact that our eyes are very good at picking up
discontinuities in the first and even second derivatives of gradients.

*looks at v3.5 source code*

OK, here's the relevant code:

At this point, x and z are values from 0 to 1, representing the coordinates
in the current square which is being interpolated:

    x = stretch(x);
    z = stretch(z);

    u = (1.0 - x);
    v = (1.0 - z);

    Result[X] = v*(u*n[0][X] + x*n[1][X]) + z*(u*n[2][X] + x*n[3][X]);
    Result[Y] = v*(u*n[0][Y] + x*n[1][Y]) + z*(u*n[2][Y] + x*n[3][Y]);
    Result[Z] = v*(u*n[0][Z] + x*n[1][Z]) + z*(u*n[2][Z] + x*n[3][Z]);

Simple bilinear interpolation; except that x and z were first run through
this "stretch" function:

static DBL stretch (DBL x)
{
  if (x <= 0.5)
  {
    x = 2.0 * x * x;
  }
  else
  {
    x = 1.0 - (2.0 * (1.0 - x) * (1.0 - x));
  }

  return(x);
}

Which pulls x and z closer to the edges of the square. I suspect that if
this function is not used, that the interpolation may appear more like the
image Warp provided. I think it's worth a shot to see if it looks better or
worse when this function is not used.

 - Slime
 [ http://www.slimeland.com/ ]


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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