summaryrefslogtreecommitdiff
path: root/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen')
-rw-r--r--Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/Makefile3
-rw-r--r--Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/README.md15
-rw-r--r--Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/testmapgen.cc86
3 files changed, 104 insertions, 0 deletions
diff --git a/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/Makefile b/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/Makefile
new file mode 100644
index 00000000000..0dc31f69d08
--- /dev/null
+++ b/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/Makefile
@@ -0,0 +1,3 @@
+all:
+ gcc -O2 -I../../deps/miniz -c ../../deps/miniz/miniz.c
+ g++ -std=c++11 -O2 -o testmapgen -I../common -I../../ -I../../deps/miniz testmapgen.cc ../../tinyexr.cc miniz.o
diff --git a/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/README.md b/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/README.md
new file mode 100644
index 00000000000..0b5fe97d5d6
--- /dev/null
+++ b/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/README.md
@@ -0,0 +1,15 @@
+# Test EXR image map gen
+
+Generate test EXR images for envmap test, composition test, etc.
+
+* white(R=1, G=1, B=1)
+* white10(R=10, G=10, B=10)
+* white100(R=100, G=100, B=100)
+
+
+## TODO
+
+* [ ] red(R=1, G=0, B=0)
+* [ ] green(R=0, G=1, B=0)
+* [ ] blue(R=0, G=0, B=1)
+* [ ] longlat test image
diff --git a/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/testmapgen.cc b/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/testmapgen.cc
new file mode 100644
index 00000000000..79514652a69
--- /dev/null
+++ b/Build/source/utils/asymptote/cudareflect/tinyexr/examples/testmapgen/testmapgen.cc
@@ -0,0 +1,86 @@
+#include <cstdio>
+#include <cstdlib>
+#include <vector>
+#include <iostream>
+
+#include "tinyexr.h"
+
+static void GenerateWhite1(size_t width, size_t height)
+{
+ std::vector<float> rgb;
+ rgb.resize(width * height * 3);
+
+ for (size_t i = 0; i < width * height * 3; i++) {
+ rgb[i] = 1.0f;
+ }
+
+ const char *err = nullptr;
+ int ret = SaveEXR(rgb.data(), int(width), int(height), /* channels */3, /* fp16? */0, "white1.exr", &err);
+ if (!ret) {
+ if (err) {
+ std::cerr << err << std::endl;
+ FreeEXRErrorMessage(err);
+ }
+ std::cerr << "failed to write white.exr" << std::endl;
+ }
+}
+
+static void GenerateWhite10(size_t width, size_t height)
+{
+ std::vector<float> rgb;
+ rgb.resize(width * height * 3);
+
+ for (size_t i = 0; i < width * height * 3; i++) {
+ rgb[i] = 10.0f;
+ }
+
+ const char *err = nullptr;
+ int ret = SaveEXR(rgb.data(), int(width), int(height), /* channels */3, /* fp16? */0, "white10.exr", &err);
+ if (!ret) {
+ if (err) {
+ std::cerr << err << std::endl;
+ FreeEXRErrorMessage(err);
+ }
+ std::cerr << "failed to write white10.exr" << std::endl;
+ }
+}
+
+static void GenerateWhite100(size_t width, size_t height)
+{
+ std::vector<float> rgb;
+ rgb.resize(width * height * 3);
+
+ for (size_t i = 0; i < width * height * 3; i++) {
+ rgb[i] = 100.0f;
+ }
+
+ const char *err = nullptr;
+ int ret = SaveEXR(rgb.data(), int(width), int(height), /* channels */3, /* fp16? */0, "white100.exr", &err);
+ if (!ret) {
+ if (err) {
+ std::cerr << err << std::endl;
+ FreeEXRErrorMessage(err);
+ }
+ std::cerr << "failed to write white100.exr" << std::endl;
+ }
+}
+
+int main(int argc, char** argv)
+{
+ int width = 512;
+ int height = 512;
+
+ if (argc > 2) {
+ width = std::min(1, atoi(argv[2]));
+ }
+
+ if (argc > 3) {
+ height = std::min(1, atoi(argv[3]));
+ }
+
+ GenerateWhite1(width, height);
+ GenerateWhite10(width, height);
+ GenerateWhite100(width, height);
+
+ return EXIT_SUCCESS;
+}