Browse Source

samples: add blue noise generation demo.

legacy
Sam Hocevar 7 years ago
parent
commit
7b2f3bdcfb
3 changed files with 45 additions and 1 deletions
  1. +1
    -0
      .gitignore
  2. +5
    -1
      doc/samples/Makefile.am
  3. +39
    -0
      doc/samples/bluenoise.cpp

+ 1
- 0
.gitignore View File

@@ -79,6 +79,7 @@ _ReSharper.*
# Our binaries
demos/lol.js/lol.js
doc/samples/benchsuite
doc/samples/bluenoise
doc/samples/btphystest
doc/samples/meshviewer/meshviewer
doc/samples/nacl_phystest


+ 5
- 1
doc/samples/Makefile.am View File

@@ -7,9 +7,13 @@ bench: benchsuite$(EXEEXT)
./benchsuite$(EXEEXT)

if BUILD_SAMPLES
noinst_PROGRAMS = benchsuite btphystest nacl_phystest simplex
noinst_PROGRAMS = bluenoise benchsuite btphystest nacl_phystest simplex
endif

bluenoise_SOURCES = bluenoise.cpp
bluenoise_CPPFLAGS = $(AM_CPPFLAGS)
bluenoise_DEPENDENCIES = @LOL_DEPS@

benchsuite_SOURCES = benchsuite.cpp \
benchmark/vector.cpp benchmark/half.cpp benchmark/trig.cpp \
benchmark/real.cpp


+ 39
- 0
doc/samples/bluenoise.cpp View File

@@ -0,0 +1,39 @@
//
// bluenoise — create a N×N blue noise kernel
//
// Copyright © 2016—2017 Sam Hocevar <sam@hocevar.net>
//
// This program is free software. It comes without any warranty, to
// the extent permitted by applicable law. You can redistribute it
// and/or modify it under the terms of the Do What the Fuck You Want
// to Public License, Version 2, as published by the WTFPL Task Force.
// See http://www.wtfpl.net/ for more details.
//

#if HAVE_CONFIG_H
# include "config.h"
#endif

#include <lol/engine.h>

using namespace lol;

int main(int argc, char **argv)
{
UNUSED(argc, argv);

ivec2 const size(64);
auto const &kernel = image::BlueNoiseKernel(size, ivec2(8));

image im(size.xy);
array2d<vec4> &data = im.Lock2D<PixelFormat::RGBA_F32>();

for (int j = 0; j < size.y; ++j)
for (int i = 0; i < size.x; ++i)
data[i][j] = vec4(vec3(kernel[i][j]), 1.0f);
im.Unlock2D(data);
im.Save("bluenoise.png");

return 0;
}


Loading…
Cancel
Save