commit 3282dca54ced1757833e6a5dccb42c79f4ec1416
parent 2bf47b15ecea79ecc7fc155d19d19b1fee6fc348
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 8 Mar 2017 16:41:16 +0100
Add and test the "spp" rendering option
Define the number of samples per pixel used to draw an image.
Diffstat:
7 files changed, 20 insertions(+), 8 deletions(-)
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
@@ -70,6 +70,7 @@ set(SOLSTICE_ARGS_DEFAULT_CAMERA_UP "0,1,0")
set(SOLSTICE_ARGS_DEFAULT_CAMERA_FOV "70") # In degrees
set(SOLSTICE_ARGS_DEFAULT_IMG_WIDTH "800")
set(SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT "600")
+set(SOLSTICE_ARGS_DEFAULT_IMG_SPP "1")
configure_file(${SOLSTICE_SOURCE_DIR}/solstice_args.h.in
${CMAKE_CURRENT_BINARY_DIR}/solstice_args.h @ONLY)
diff --git a/doc/cli b/doc/cli
@@ -13,7 +13,7 @@ solstice
-t INTEGER # Threads count
INPUT # Input scene in YAML
-solstice -r img=1280x720:pos=0,100,0:tgt=0,0,0:up=0,1,0:fov=70
+solstice -r img=1280x720:pos=0,100,0:tgt=0,0,0:up=0,1,0:fov=70:spp=1
solstice -g format=obj:split-group=1
-d and -D are exclusive
@@ -37,7 +37,7 @@ solstice -g format=obj:split-group=1
<rendering-option>[:<rendering-option> ... ]
<rendering-option> ::=
- <fov> | <img> | <position> | <target> | <up>
+ <fov> | <img> | <position> | <samples-per-pixel> | <target> | <up>
<dump> ::=
format=<dump-format>[:split=<split-mode>]
@@ -57,6 +57,9 @@ solstice -g format=obj:split-group=1
<position> ::=
pos=<real3>
+<samples-per-pixel> ::=
+ spp=<INTEGER>
+
<target> ::=
tgt=<real3>
diff --git a/src/solstice.c b/src/solstice.c
@@ -599,6 +599,7 @@ solstice_init
if(res != RES_OK) goto error;
res = setup_framebuffer(solstice, args);
if(res != RES_OK) goto error;
+ solstice->spp = args->img.spp;
}
exit:
diff --git a/src/solstice.h b/src/solstice.h
@@ -86,6 +86,7 @@ struct solstice {
/* Rendering */
struct ssol_camera* camera;
struct ssol_image* framebuffer;
+ unsigned spp; /* #Samples per pixel */
/* Dump geometry */
enum solstice_args_dump_format dump_format;
diff --git a/src/solstice_args.c b/src/solstice_args.c
@@ -241,7 +241,14 @@ parse_rendering_option(const char* str, struct solstice_args* args)
goto error;
}
args->camera.auto_look_at = 0; /* Disable auto look at */
- } else if(!strcmp(key, "tgt")) {
+ } else if(!strcmp(key, "spp")) { /*# Samples per pixel */
+ res = cstr_to_uint(val, &args->img.spp);
+ if(res == RES_OK && !args->img.spp) res = RES_BAD_ARG;
+ if(res != RES_OK) {
+ fprintf(stderr, "Invalid number of samples per pixel `%s'.\n", val);
+ goto error;
+ }
+ } else if(!strcmp(key, "tgt")) { /* Camera target */
res = cstr_to_list_double(val, ',', args->camera.tgt, &len, 3);
if(res == RES_OK && len != 3) res = RES_BAD_ARG;
if(res != RES_OK) {
@@ -258,9 +265,6 @@ parse_rendering_option(const char* str, struct solstice_args* args)
}
} else {
fprintf(stderr, "Invalid rendering option `%s'.\n", val);
- /* TODO remove this. The man page will be sufficient */
- fprintf(stderr,
-"Valid options are: fov=FOV:img=WIDTHxHEIGHT:pos=X,Y,Z:tgt=X,Y,Z:up=X,Y,Z\n");
res = RES_BAD_ARG;
goto error;
}
diff --git a/src/solstice_args.h.in b/src/solstice_args.h.in
@@ -57,6 +57,7 @@ struct solstice_args {
struct {
unsigned long width;
unsigned long height;
+ unsigned spp; /* Samples per pixel */
} img;
enum solstice_args_dump_format dump_format;
@@ -92,7 +93,8 @@ static const struct solstice_args SOLSTICE_ARGS_NULL = SOLSTICE_ARGS_NULL__;
\
{ /* Image */ \
@SOLSTICE_ARGS_DEFAULT_IMG_WIDTH@, \
- @SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT@ \
+ @SOLSTICE_ARGS_DEFAULT_IMG_HEIGHT@, \
+ @SOLSTICE_ARGS_DEFAULT_IMG_SPP@ \
}, \
\
SOLSTICE_ARGS_DUMP_NONE, /* Dump format */ \
diff --git a/src/solstice_draw.c b/src/solstice_draw.c
@@ -77,7 +77,7 @@ solstice_draw(struct solstice* solstice)
}
res = ssol_draw_draft(solstice->scene, solstice->camera, layout.width,
- layout.height, 1, ssol_image_write, solstice->framebuffer);
+ layout.height, solstice->spp, ssol_image_write, solstice->framebuffer);
if(res != RES_OK) {
fprintf(stderr, "Rendering error\n");
goto error;