Kaynağa Gözat

simplex: use scaling values that match Stefan Gustavson’s paper.

undefined
Sam Hocevar 10 yıl önce
ebeveyn
işleme
4c95301d31
2 değiştirilmiş dosya ile 7 ekleme ve 6 silme
  1. +2
    -1
      demos/test/simplex.cpp
  2. +5
    -5
      src/lol/math/simplex_interpolator.h

+ 2
- 1
demos/test/simplex.cpp Dosyayı Görüntüle

@@ -42,9 +42,10 @@ int main(int argc, char **argv)
for (int i = 0; i < size.x; ++i)
{
float p = 0.5f * s.Interp(zoom * vec2(i, j));
#if 0
#if 1
for (int k = 2; k < 128; k *= 2)
p += 0.5f / k * s.Interp(zoom * k * vec2(i, j));
//p += 0.5f / k * lol::abs(s.Interp(zoom * k * vec2(i, j)));
#endif
data[i][j] = vec4(saturate(0.5f + p), 0.f, 0.f, 1.f);
}


+ 5
- 5
src/lol/math/simplex_interpolator.h Dosyayı Görüntüle

@@ -72,8 +72,10 @@ protected:
vec_t<float, N> const delta = pos - corner;
vec_t<float, N> const &gradient = this->m_gradients[origin];

// FIXME: where does the 0.75 come from?
float dist = 0.5f - 0.75f * sqlength(delta);
/* We use 4/3 because the maximum radius of influence for
* a given corner is sqrt(3/4). FIXME: check whether this
* holds for higher dimensions. */
float dist = 1.0f - 4.f / 3.f * sqlength(delta);
if (dist > 0)
{
dist *= dist;
@@ -88,11 +90,9 @@ protected:
}
}

// Approximative scaling factor “100” seems to work well
// ie. gives a max value of 1 (a bit more in fact) for normed gradients
// FIXME: another paper uses the value 70 for dimension 2, 32 for
// dimension 3, and 27 for dimension 4; find where this comes from.
return result * 100.f;
return result * 70.f / 16.f;
}

/* For a given position [0…1]^n inside a square/cube/hypercube etc.,


Yükleniyor…
İptal
Kaydet