Changeset 3721


Ignore:
Timestamp:
Dec 23, 2014, 3:02:35 PM (7 years ago)
Author:
sam
Message:

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

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/demos/test/simplex.cpp

    r3720 r3721  
    4343    {
    4444        float p = 0.5f * s.Interp(zoom * vec2(i, j));
    45 #if 0
     45#if 1
    4646        for (int k = 2; k < 128; k *= 2)
    4747            p += 0.5f / k * s.Interp(zoom * k * vec2(i, j));
     48            //p += 0.5f / k * lol::abs(s.Interp(zoom * k * vec2(i, j)));
    4849#endif
    4950        data[i][j] = vec4(saturate(0.5f + p), 0.f, 0.f, 1.f);
  • trunk/src/lol/math/simplex_interpolator.h

    r3720 r3721  
    7373            vec_t<float, N> const &gradient = this->m_gradients[origin];
    7474
    75             // FIXME: where does the 0.75 come from?
    76             float dist = 0.5f - 0.75f * sqlength(delta);
     75            /* We use 4/3 because the maximum radius of influence for
     76             * a given corner is sqrt(3/4). FIXME: check whether this
     77             * holds for higher dimensions. */
     78            float dist = 1.0f - 4.f / 3.f * sqlength(delta);
    7779            if (dist > 0)
    7880            {
     
    8991        }
    9092
    91         // Approximative scaling factor “100” seems to work well
    92         // ie. gives a max value of 1 (a bit more in fact) for normed gradients
    9393        // FIXME: another paper uses the value 70 for dimension 2, 32 for
    9494        // dimension 3, and 27 for dimension 4; find where this comes from.
    95         return result * 100.f;
     95        return result * 70.f / 16.f;
    9696    }
    9797
Note: See TracChangeset for help on using the changeset viewer.