2016-11-12 13:19:22 +00:00
|
|
|
#define GLM_ENABLE_EXPERIMENTAL
|
2012-04-07 01:30:26 +00:00
|
|
|
#include <glm/gtc/noise.hpp>
|
2017-08-21 08:36:27 +00:00
|
|
|
#include <glm/gtc/type_precision.hpp>
|
2017-08-08 13:17:25 +00:00
|
|
|
#include <glm/gtx/raw_data.hpp>
|
2016-11-20 22:02:20 +00:00
|
|
|
|
2018-09-26 10:51:31 +00:00
|
|
|
static int test_simplex_float()
|
2011-09-27 09:22:29 +00:00
|
|
|
{
|
2017-08-08 13:17:25 +00:00
|
|
|
int Error = 0;
|
2011-09-27 09:22:29 +00:00
|
|
|
|
2017-08-08 13:17:25 +00:00
|
|
|
glm::u8vec4 const PixelSimplex2D(glm::byte(glm::abs(glm::simplex(glm::vec2(0.f, 0.f))) * 255.f));
|
|
|
|
glm::u8vec4 const PixelSimplex3D(glm::byte(glm::abs(glm::simplex(glm::vec3(0.f, 0.f, 0.f))) * 255.f));
|
|
|
|
glm::u8vec4 const PixelSimplex4D(glm::byte(glm::abs(glm::simplex(glm::vec4(0.f, 0.f, 0.f, 0.f))) * 255.f));
|
2011-09-27 09:22:29 +00:00
|
|
|
|
2017-08-08 13:17:25 +00:00
|
|
|
return Error;
|
2011-09-27 09:22:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-26 10:51:31 +00:00
|
|
|
static int test_simplex_double()
|
|
|
|
{
|
|
|
|
int Error = 0;
|
|
|
|
|
2018-09-26 12:52:55 +00:00
|
|
|
glm::u8vec4 const PixelSimplex2D(glm::byte(glm::abs(glm::simplex(glm::dvec2(0.f, 0.f))) * 255.));
|
|
|
|
glm::u8vec4 const PixelSimplex3D(glm::byte(glm::abs(glm::simplex(glm::dvec3(0.f, 0.f, 0.f))) * 255.));
|
|
|
|
glm::u8vec4 const PixelSimplex4D(glm::byte(glm::abs(glm::simplex(glm::dvec4(0.f, 0.f, 0.f, 0.f))) * 255.));
|
2018-09-26 10:51:31 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_perlin_float()
|
2011-09-27 09:22:29 +00:00
|
|
|
{
|
2017-08-08 13:17:25 +00:00
|
|
|
int Error = 0;
|
2011-09-27 09:22:29 +00:00
|
|
|
|
2017-08-08 13:17:25 +00:00
|
|
|
glm::u8vec4 const PixelPerlin2D(glm::byte(glm::abs(glm::perlin(glm::vec2(0.f, 0.f))) * 255.f));
|
|
|
|
glm::u8vec4 const PixelPerlin3D(glm::byte(glm::abs(glm::perlin(glm::vec3(0.f, 0.f, 0.f))) * 255.f));
|
|
|
|
glm::u8vec4 const PixelPerlin4D(glm::byte(glm::abs(glm::perlin(glm::vec4(0.f, 0.f, 0.f, 0.f))) * 255.f));
|
2011-09-27 09:22:29 +00:00
|
|
|
|
2017-08-08 13:17:25 +00:00
|
|
|
return Error;
|
2011-09-27 09:22:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-26 10:51:31 +00:00
|
|
|
static int test_perlin_double()
|
|
|
|
{
|
|
|
|
int Error = 0;
|
|
|
|
|
2018-09-26 12:52:55 +00:00
|
|
|
glm::u8vec4 const PixelPerlin2D(glm::byte(glm::abs(glm::perlin(glm::dvec2(0.f, 0.f))) * 255.));
|
|
|
|
glm::u8vec4 const PixelPerlin3D(glm::byte(glm::abs(glm::perlin(glm::dvec3(0.f, 0.f, 0.f))) * 255.));
|
|
|
|
glm::u8vec4 const PixelPerlin4D(glm::byte(glm::abs(glm::perlin(glm::dvec4(0.f, 0.f, 0.f, 0.f))) * 255.));
|
2018-09-26 10:51:31 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int test_perlin_pedioric_float()
|
2011-09-27 09:22:29 +00:00
|
|
|
{
|
2017-08-08 13:17:25 +00:00
|
|
|
int Error = 0;
|
2011-09-27 09:22:29 +00:00
|
|
|
|
2017-08-08 13:17:25 +00:00
|
|
|
glm::u8vec4 const PixelPeriodic2D(glm::byte(glm::abs(glm::perlin(glm::vec2(0.f, 0.f), glm::vec2(2.0f))) * 255.f));
|
|
|
|
glm::u8vec4 const PixelPeriodic3D(glm::byte(glm::abs(glm::perlin(glm::vec3(0.f, 0.f, 0.f), glm::vec3(2.0f))) * 255.f));
|
|
|
|
glm::u8vec4 const PixelPeriodic4D(glm::byte(glm::abs(glm::perlin(glm::vec4(0.f, 0.f, 0.f, 0.f), glm::vec4(2.0f))) * 255.f));
|
2011-09-27 09:22:29 +00:00
|
|
|
|
2017-08-08 13:17:25 +00:00
|
|
|
return Error;
|
2011-09-27 09:22:29 +00:00
|
|
|
}
|
|
|
|
|
2018-09-26 10:51:31 +00:00
|
|
|
static int test_perlin_pedioric_double()
|
|
|
|
{
|
|
|
|
int Error = 0;
|
|
|
|
|
2018-09-26 13:08:04 +00:00
|
|
|
glm::u8vec4 const PixelPeriodic2D(glm::byte(glm::abs(glm::perlin(glm::dvec2(0.f, 0.f), glm::dvec2(2.0))) * 255.));
|
|
|
|
glm::u8vec4 const PixelPeriodic3D(glm::byte(glm::abs(glm::perlin(glm::dvec3(0.f, 0.f, 0.f), glm::dvec3(2.0))) * 255.));
|
|
|
|
glm::u8vec4 const PixelPeriodic4D(glm::byte(glm::abs(glm::perlin(glm::dvec4(0.f, 0.f, 0.f, 0.f), glm::dvec4(2.0))) * 255.));
|
2018-09-26 10:51:31 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|
|
|
|
|
2011-09-27 09:22:29 +00:00
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int Error = 0;
|
|
|
|
|
2018-09-26 10:51:31 +00:00
|
|
|
Error += test_simplex_float();
|
|
|
|
Error += test_simplex_double();
|
|
|
|
|
|
|
|
Error += test_perlin_float();
|
|
|
|
Error += test_perlin_double();
|
|
|
|
|
|
|
|
Error += test_perlin_pedioric_float();
|
|
|
|
Error += test_perlin_pedioric_double();
|
2011-09-27 09:22:29 +00:00
|
|
|
|
|
|
|
return Error;
|
|
|
|
}
|