25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

40 lines
983 B

  1. //
  2. // bluenoise — create a N×N blue noise kernel
  3. //
  4. // Copyright © 2016—2017 Sam Hocevar <sam@hocevar.net>
  5. //
  6. // This program is free software. It comes without any warranty, to
  7. // the extent permitted by applicable law. You can redistribute it
  8. // and/or modify it under the terms of the Do What the Fuck You Want
  9. // to Public License, Version 2, as published by the WTFPL Task Force.
  10. // See http://www.wtfpl.net/ for more details.
  11. //
  12. #if HAVE_CONFIG_H
  13. # include "config.h"
  14. #endif
  15. #include <lol/engine.h>
  16. using namespace lol;
  17. int main(int argc, char **argv)
  18. {
  19. UNUSED(argc, argv);
  20. ivec2 const size(64);
  21. auto const &kernel = image::kernel::blue_noise(size, ivec2(8));
  22. image im(size.xy);
  23. array2d<vec4> &data = im.lock2d<PixelFormat::RGBA_F32>();
  24. for (int j = 0; j < size.y; ++j)
  25. for (int i = 0; i < size.x; ++i)
  26. data[i][j] = vec4(vec3(kernel[i][j]), 1.0f);
  27. im.unlock2d(data);
  28. im.save("bluenoise.png");
  29. return 0;
  30. }