Made samples per bucket configurable.

This commit is contained in:
Nathan Vegdahl 2016-10-16 14:55:00 -07:00
parent bb4e57795f
commit 0e8d708ff0
5 changed files with 54 additions and 40 deletions

View File

@ -40,6 +40,11 @@ class RenderPsychopathSettingsScene(PropertyGroup):
min=1, max=65536, default=16
)
max_samples_per_bucket = IntProperty(
name="Max Samples Per Bucket", description="How many samples to simultaneously calculate per thread; indirectly determines bucket size",
min=1, max=2**28, soft_max=2**16, default=4096
)
dicing_rate = FloatProperty(
name="Dicing Rate", description="The target microgeometry width in pixels",
min=0.0001, max=100.0, soft_min=0.125, soft_max=1.0, default=0.25

View File

@ -49,7 +49,7 @@ class PsychopathRender(bpy.types.RenderEngine):
return False
# TODO: figure out command line options
args = ["-i", psy_filepath]
args = ["--spb", str(scene.psychopath.max_samples_per_bucket), "-i", psy_filepath]
# Start Rendering!
try:

View File

@ -46,6 +46,9 @@ class RENDER_PT_psychopath_render_settings(PsychopathPanel, bpy.types.Panel):
col.prop(scene.psychopath, "shutter_start")
col.prop(scene.psychopath, "shutter_end")
col.label(text="Performance")
col.prop(scene.psychopath, "max_samples_per_bucket")
class RENDER_PT_psychopath_export_settings(PsychopathPanel, bpy.types.Panel):
bl_label = "Export Settings"

View File

@ -72,6 +72,7 @@ Usage:
Options:
-i <file>, --input <file> Input .psy file.
-s <n>, --spp <n> Number of samples per pixel.
-b <n>, --spb <n> Maxmimum number of samples per bucket (determines bucket size).
-t <n>, --threads <n> Number of threads to render with. Defaults
to the number of logical cores on the system.
--dev Show useful dev/debug info.
@ -83,6 +84,7 @@ Options:
struct Args {
flag_input: Option<String>,
flag_spp: Option<usize>,
flag_spb: Option<usize>,
flag_threads: Option<usize>,
flag_dev: bool,
flag_version: bool,
@ -141,6 +143,12 @@ fn main() {
r.spp = spp;
}
let max_samples_per_bucket = if let Some(max_samples_per_bucket) = args.flag_spb {
max_samples_per_bucket as u32
} else {
4096
};
let thread_count = if let Some(threads) = args.flag_threads {
threads as u32
} else {
@ -150,7 +158,7 @@ fn main() {
println!("\tBuilt scene in {:.3}s", t.tick());
println!("Rendering scene with {} threads...", thread_count);
let mut image = r.render(thread_count);
let mut image = r.render(max_samples_per_bucket, thread_count);
println!("\tRendered scene in {:.3}s", t.tick());
println!("Writing image to disk...");

View File

@ -31,7 +31,7 @@ pub struct Renderer {
}
impl Renderer {
pub fn render(&self, thread_count: u32) -> Image {
pub fn render(&self, max_samples_per_bucket: u32, thread_count: u32) -> Image {
let mut tpool = Pool::new(thread_count);
let image = Image::new(self.resolution.0, self.resolution.1);
@ -174,12 +174,10 @@ impl Renderer {
print!("0.00%");
let _ = io::stdout().flush();
// Determine bucket size based on a target number of samples
// per bucket.
// TODO: make target samples per bucket configurable
let target_samples_per_bucket = 1usize << 12;
// Determine bucket size based on the per-thread maximum number of samples to
// calculate at a time.
let (bucket_w, bucket_h) = {
let target_pixels_per_bucket = target_samples_per_bucket as f64 / self.spp as f64;
let target_pixels_per_bucket = max_samples_per_bucket as f64 / self.spp as f64;
let target_bucket_dim = if target_pixels_per_bucket.sqrt() < 1.0 {
1usize
} else {