diff options
author | Sam Kottler <dev@samkottler.net> | 2020-08-13 23:17:04 +0300 |
---|---|---|
committer | Sam Kottler <dev@samkottler.net> | 2020-08-13 23:17:04 +0300 |
commit | 3b49ca465f708270b69647dc7425958d9e5793c2 (patch) | |
tree | 3372b00bcc60433dba499acc4340307189f7ce76 | |
parent | 7c38d008de5ebdcb96ebdd67b8dc459d5551702f (diff) |
Finished bringing light tree code up to date
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 2 | ||||
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 34 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 7 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_bake.h | 9 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_emission.h | 10 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path.h | 13 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_branched.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/kernel_path_surface.h | 1 | ||||
-rw-r--r-- | intern/cycles/kernel/split/kernel_direct_lighting.h | 18 | ||||
-rw-r--r-- | intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h | 11 | ||||
-rw-r--r-- | intern/cycles/render/light.cpp | 2 | ||||
-rw-r--r-- | intern/cycles/render/mesh_volume.cpp | 57 | ||||
m--------- | release/datafiles/locale | 0 | ||||
m--------- | release/scripts/addons | 0 | ||||
m--------- | release/scripts/addons_contrib | 0 | ||||
-rw-r--r-- | source/blender/python/mathutils/mathutils_bvhtree.c | 3 | ||||
m--------- | source/tools | 0 |
17 files changed, 89 insertions, 82 deletions
diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index 7e9338ab421..337329bfad2 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -297,7 +297,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): default=False, ) - splitting_threshold = FloatProperty( + splitting_threshold: FloatProperty( name="Splitting", description="Amount of lights to sample at a time, from one light at 0.0, to adaptively more lights as needed, to all lights at 1.0", min=0.0, max=1.0, diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 39cb1477c33..2dfa50a9aa3 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -326,13 +326,34 @@ class CYCLES_RENDER_PT_sampling_advanced(CyclesButtonsPanel, Panel): layout.row().prop(cscene, "use_layer_samples") break +class CYCLES_RENDER_PT_sampling_light_tree(CyclesButtonsPanel, Panel): + bl_label = "Light Tree" + bl_parent_id = "CYCLES_RENDER_PT_sampling" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + return (context.scene.cycles.feature_set == 'EXPERIMENTAL') + + def draw_header(self, context): + layout = self.layout + scene = context.scene + cscene = scene.cycles + + layout.prop(cscene, "use_light_tree", text="") + + def draw(self, context): + layout = self.layout + layout.use_property_split = True + layout.use_property_decorate = False + + scene = context.scene + cscene = scene.cycles + + layout.active = cscene.use_light_tree row = layout.row(align=True) - row.label(text="Experimental:") - row.prop(cscene, "use_light_tree", text="Light Tree") - if cscene.use_light_tree and use_branched_path(context): - row = layout.row(align=True) - row.label(text="") # create empty column - row.prop(cscene, "splitting_threshold", text="Splitting") + row.label(text="") # create empty column + row.prop(cscene, "splitting_threshold", text="Splitting") class CYCLES_RENDER_PT_sampling_total(CyclesButtonsPanel, Panel): @@ -2280,6 +2301,7 @@ classes = ( CYCLES_RENDER_PT_sampling_adaptive, CYCLES_RENDER_PT_sampling_denoising, CYCLES_RENDER_PT_sampling_advanced, + CYCLES_RENDER_PT_sampling_light_tree, CYCLES_RENDER_PT_light_paths, CYCLES_RENDER_PT_light_paths_max_bounces, CYCLES_RENDER_PT_light_paths_clamping, diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index f806569c389..7d0c188c5c3 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -305,12 +305,7 @@ void BlenderSync::sync_integrator() cscene, "progressive", Integrator::NUM_METHODS, Integrator::PATH); integrator->use_light_tree = get_boolean(cscene, "use_light_tree"); - if (get_enum(cscene, "progressive") == 0) { - integrator->splitting_threshold = get_float(cscene, "splitting_threshold"); - } - else { // Not using branched path tracing - integrator->splitting_threshold = 0.0f; - } + integrator->splitting_threshold = get_float(cscene, "splitting_threshold"); integrator->sample_all_lights_direct = get_boolean(cscene, "sample_all_lights_direct"); integrator->sample_all_lights_indirect = get_boolean(cscene, "sample_all_lights_indirect"); integrator->light_sampling_threshold = get_float(cscene, "light_sampling_threshold"); diff --git a/intern/cycles/kernel/kernel_bake.h b/intern/cycles/kernel/kernel_bake.h index 3e861be5b6c..4bd6fa84c3a 100644 --- a/intern/cycles/kernel/kernel_bake.h +++ b/intern/cycles/kernel/kernel_bake.h @@ -64,9 +64,8 @@ ccl_device_noinline void compute_light_pass( /* sample emission */ if ((pass_filter & BAKE_FILTER_EMISSION) && (sd->flag & SD_EMISSION)) { - bool is_volume_boundary = (state.volume_bounce > 0) || (state.volume_bounds_bounce > 0); float3 emission = indirect_primitive_emission( - kg, sd, 0.0f, sd->P_pick, sd->N_pick, state.flag, state.ray_pdf, is_volume_boundary); + kg, sd, 0.0f, sd->P_pick, sd->N_pick, state.flag, state.ray_pdf); path_radiance_accum_emission(kg, L, &state, throughput, emission); } @@ -83,9 +82,9 @@ ccl_device_noinline void compute_light_pass( kg, sd, emission_sd, L, &state, &ray, &throughput, &ss_indirect)) { while (ss_indirect.num_rays) { kernel_path_subsurface_setup_indirect(kg, &ss_indirect, &state, &ray, L, &throughput); - kernel_path_indirect(kg, &indirect_sd, emission_sd, &ray, throughput, &state, L); indirect_sd.P_pick = sd->P_pick; indirect_sd.N_pick = sd->N_pick; + indirect_sd.t_pick = sd->t_pick; kernel_path_indirect(kg, &indirect_sd, emission_sd, &ray, throughput, &state, L); } is_sss_sample = true; @@ -104,6 +103,7 @@ ccl_device_noinline void compute_light_pass( /* compute indirect light */ indirect_sd.P_pick = sd->P_pick; indirect_sd.N_pick = sd->N_pick; + indirect_sd.t_pick = sd->t_pick; kernel_path_indirect(kg, &indirect_sd, emission_sd, &ray, throughput, &state, L); /* sum and reset indirect light pass variables for the next samples */ @@ -123,9 +123,8 @@ ccl_device_noinline void compute_light_pass( /* sample emission */ if ((pass_filter & BAKE_FILTER_EMISSION) && (sd->flag & SD_EMISSION)) { - bool is_volume_boundary = (state.volume_bounce > 0) || (state.volume_bounds_bounce > 0); float3 emission = indirect_primitive_emission( - kg, sd, 0.0f, sd->P_pick, sd->N_pick, state.flag, state.ray_pdf, is_volume_boundary); + kg, sd, 0.0f, sd->P_pick, sd->N_pick, state.flag, state.ray_pdf); path_radiance_accum_emission(kg, L, &state, throughput, emission); } diff --git a/intern/cycles/kernel/kernel_emission.h b/intern/cycles/kernel/kernel_emission.h index 47a6dfa1e1d..2a864ab24d0 100644 --- a/intern/cycles/kernel/kernel_emission.h +++ b/intern/cycles/kernel/kernel_emission.h @@ -206,14 +206,8 @@ ccl_device_noinline_cpu bool direct_emission(KernelGlobals *kg, /* Indirect Primitive Emission */ -ccl_device_noinline_cpu float3 indirect_primitive_emission(KernelGlobals *kg, - ShaderData *sd, - float t, - float3 P, - float3 N, - int path_flag, - float bsdf_pdf, - bool has_volume) +ccl_device_noinline_cpu float3 indirect_primitive_emission( + KernelGlobals *kg, ShaderData *sd, float t, float3 P, float3 N, int path_flag, float bsdf_pdf) { /* evaluate emissive closure */ float3 L = shader_emissive_eval(sd); diff --git a/intern/cycles/kernel/kernel_path.h b/intern/cycles/kernel/kernel_path.h index 2ba3b1c4fdc..b2f207bc41f 100644 --- a/intern/cycles/kernel/kernel_path.h +++ b/intern/cycles/kernel/kernel_path.h @@ -264,8 +264,7 @@ ccl_device_forceinline bool kernel_path_shader_apply(KernelGlobals *kg, float3 throughput, ShaderData *emission_sd, PathRadiance *L, - ccl_global float *buffer, - bool has_volume) + ccl_global float *buffer) { PROFILING_INIT(kg, PROFILING_SHADER_APPLY); @@ -328,7 +327,7 @@ ccl_device_forceinline bool kernel_path_shader_apply(KernelGlobals *kg, float ray_length = state->ray_t + sd->ray_length; float3 emission = indirect_primitive_emission( - kg, sd, ray_length, P_pick, N_pick, state->flag, state->ray_pdf, has_volume); + kg, sd, ray_length, P_pick, N_pick, state->flag, state->ray_pdf); path_radiance_accum_emission(kg, L, state, throughput, emission); } #endif /* __EMISSION__ */ @@ -442,7 +441,6 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, } /* Setup shader data. */ - bool has_volume = (sd->flag & SD_HAS_VOLUME) != 0; shader_setup_from_ray(kg, sd, &isect, ray); /* Skip most work for volume bounding surface. */ @@ -455,8 +453,7 @@ ccl_device void kernel_path_indirect(KernelGlobals *kg, shader_prepare_closures(sd, state); /* Apply shadow catcher, holdout, emission. */ - if (!kernel_path_shader_apply( - kg, sd, state, ray, throughput, emission_sd, L, NULL, has_volume)) { + if (!kernel_path_shader_apply(kg, sd, state, ray, throughput, emission_sd, L, NULL)) { break; } @@ -584,7 +581,6 @@ ccl_device_forceinline void kernel_path_integrate(KernelGlobals *kg, } /* Setup shader data. */ - bool has_volume = (sd.flag & SD_HAS_VOLUME) != 0; shader_setup_from_ray(kg, &sd, &isect, ray); /* Skip most work for volume bounding surface. */ @@ -597,8 +593,7 @@ ccl_device_forceinline void kernel_path_integrate(KernelGlobals *kg, shader_prepare_closures(&sd, state); /* Apply shadow catcher, holdout, emission. */ - if (!kernel_path_shader_apply( - kg, &sd, state, ray, throughput, emission_sd, L, buffer, has_volume)) { + if (!kernel_path_shader_apply(kg, &sd, state, ray, throughput, emission_sd, L, buffer)) { break; } diff --git a/intern/cycles/kernel/kernel_path_branched.h b/intern/cycles/kernel/kernel_path_branched.h index 2f7c3d8ae82..0c1ba658c5e 100644 --- a/intern/cycles/kernel/kernel_path_branched.h +++ b/intern/cycles/kernel/kernel_path_branched.h @@ -423,7 +423,6 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg, } /* Setup and evaluate shader. */ - bool has_volume = (sd.flag & SD_HAS_VOLUME) != 0; shader_setup_from_ray(kg, &sd, &isect, &ray); /* Skip most work for volume bounding surface. */ @@ -435,8 +434,7 @@ ccl_device void kernel_branched_path_integrate(KernelGlobals *kg, shader_merge_closures(&sd); /* Apply shadow catcher, holdout, emission. */ - if (!kernel_path_shader_apply( - kg, &sd, &state, &ray, throughput, emission_sd, L, buffer, has_volume)) { + if (!kernel_path_shader_apply(kg, &sd, &state, &ray, throughput, emission_sd, L, buffer)) { break; } diff --git a/intern/cycles/kernel/kernel_path_surface.h b/intern/cycles/kernel/kernel_path_surface.h index 9fd5312fbb4..71275bda499 100644 --- a/intern/cycles/kernel/kernel_path_surface.h +++ b/intern/cycles/kernel/kernel_path_surface.h @@ -524,7 +524,6 @@ ccl_device_inline void kernel_path_surface_connect_light(KernelGlobals *kg, # endif if (kernel_data.integrator.use_direct_light && (sd->flag & SD_BSDF_HAS_EVAL)) { - bool has_volume = ((sd->flag & SD_HAS_VOLUME) != 0); float light_u, light_v; path_state_rng_2D(kg, state, PRNG_LIGHT_U, &light_u, &light_v); diff --git a/intern/cycles/kernel/split/kernel_direct_lighting.h b/intern/cycles/kernel/split/kernel_direct_lighting.h index 9560d338030..f4eface860b 100644 --- a/intern/cycles/kernel/split/kernel_direct_lighting.h +++ b/intern/cycles/kernel/split/kernel_direct_lighting.h @@ -87,15 +87,15 @@ ccl_device void kernel_direct_lighting(KernelGlobals *kg, LightSample ls; if (light_sample(kg, - -1, - light_u, - light_v, - sd->time, - sd->P_pick, - sd->N_pick, - -1.0f, - state->bounce, - &ls)) { + -1, + light_u, + light_v, + sd->time, + sd->P_pick, + sd->N_pick, + -1.0f, + state->bounce, + &ls)) { Ray light_ray; light_ray.time = sd->time; diff --git a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h index 630625fa2ac..56cdb22bba3 100644 --- a/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h +++ b/intern/cycles/kernel/split/kernel_holdout_emission_blurring_pathtermination_ao.h @@ -107,16 +107,7 @@ ccl_device void kernel_holdout_emission_blurring_pathtermination_ao( throughput = kernel_split_state.throughput[ray_index]; state = &kernel_split_state.path_state[ray_index]; - if (!kernel_path_shader_apply(kg, - sd, - state, - ray, - throughput, - emission_sd, - L, - buffer, - false)) // todo: check if starting from volume - { + if (!kernel_path_shader_apply(kg, sd, state, ray, throughput, emission_sd, L, buffer)) { kernel_split_path_end(kg, ray_index); } } diff --git a/intern/cycles/render/light.cpp b/intern/cycles/render/light.cpp index 40a7a588189..9193067f444 100644 --- a/intern/cycles/render/light.cpp +++ b/intern/cycles/render/light.cpp @@ -1492,7 +1492,7 @@ int2 LightManager::get_background_map_resolution(const Light *background_light, foreach (ShaderNode *node, shader->graph->nodes) { if (node->type == EnvironmentTextureNode::node_type) { EnvironmentTextureNode *env = (EnvironmentTextureNode *)node; - ImageMetaData metadata = env->handle.metadata();; + ImageMetaData metadata = env->handle.metadata(); res.x = max(res.x, metadata.width); res.y = max(res.y, metadata.height); } diff --git a/intern/cycles/render/mesh_volume.cpp b/intern/cycles/render/mesh_volume.cpp index 70189ea4812..0b57243fec1 100644 --- a/intern/cycles/render/mesh_volume.cpp +++ b/intern/cycles/render/mesh_volume.cpp @@ -159,7 +159,7 @@ class VolumeMeshBuilder { bool empty_grid() const; #ifdef WITH_OPENVDB - template <typename GridType> + template<typename GridType> void merge_grid(openvdb::GridBase::ConstPtr grid, bool do_clipping, float volume_clipping) { typename GridType::ConstPtr typed_grid = openvdb::gridConstPtrCast<GridType>(grid); @@ -189,7 +189,9 @@ VolumeMeshBuilder::VolumeMeshBuilder() } #ifdef WITH_OPENVDB -void VolumeMeshBuilder::add_grid(openvdb::GridBase::ConstPtr grid, bool do_clipping, float volume_clipping) +void VolumeMeshBuilder::add_grid(openvdb::GridBase::ConstPtr grid, + bool do_clipping, + float volume_clipping) { /* set the transform of our grid from the first one */ if (first_grid) { @@ -415,22 +417,38 @@ static openvdb::GridBase::ConstPtr openvdb_grid_from_device_texture(device_textu typename GridType::Ptr sparse = GridType::create(ValueType(0.0f)); openvdb::tools::copyFromDense(dense, *sparse, ValueType(volume_clipping)); - /* copyFromDense will remove any leaf node that contains constant data and replace it with a tile, - * however, we need to preserve the leaves in order to generate the mesh, so revoxelize the leaves - * that were pruned. This should not affect areas that were skipped due to the volume_clipping parameter. */ + /* copyFromDense will remove any leaf node that contains constant data and replace it with a + * tile, however, we need to preserve the leaves in order to generate the mesh, so revoxelize the + * leaves that were pruned. This should not affect areas that were skipped due to the + * volume_clipping parameter. */ sparse->tree().voxelizeActiveTiles(); /* Compute index to world matrix. */ - float3 voxel_size = make_float3(1.0f / image_memory->data_width, 1.0f / image_memory->data_height, 1.0f / image_memory->data_depth); + float3 voxel_size = make_float3(1.0f / image_memory->data_width, + 1.0f / image_memory->data_height, + 1.0f / image_memory->data_depth); transform_3d = transform_inverse(transform_3d); - openvdb::Mat4R index_to_world_mat((double)(voxel_size.x * transform_3d[0][0]), 0.0, 0.0, 0.0, - 0.0, (double)(voxel_size.y * transform_3d[1][1]), 0.0, 0.0, - 0.0, 0.0, (double)(voxel_size.z * transform_3d[2][2]), 0.0, - (double)transform_3d[0][3], (double)transform_3d[1][3], (double)transform_3d[2][3], 1.0); - - openvdb::math::Transform::Ptr index_to_world_tfm = openvdb::math::Transform::createLinearTransform(index_to_world_mat); + openvdb::Mat4R index_to_world_mat((double)(voxel_size.x * transform_3d[0][0]), + 0.0, + 0.0, + 0.0, + 0.0, + (double)(voxel_size.y * transform_3d[1][1]), + 0.0, + 0.0, + 0.0, + 0.0, + (double)(voxel_size.z * transform_3d[2][2]), + 0.0, + (double)transform_3d[0][3], + (double)transform_3d[1][3], + (double)transform_3d[2][3], + 1.0); + + openvdb::math::Transform::Ptr index_to_world_tfm = + openvdb::math::Transform::createLinearTransform(index_to_world_mat); sparse->setTransform(index_to_world_tfm); @@ -472,19 +490,16 @@ void GeometryManager::create_volume_mesh(Mesh *mesh, Progress &progress) device_texture *image_memory = handle.image_memory(); if (image_memory->data_elements == 1) { - grid = openvdb_grid_from_device_texture<openvdb::FloatGrid>(image_memory, - mesh->volume_clipping, - handle.metadata().transform_3d); + grid = openvdb_grid_from_device_texture<openvdb::FloatGrid>( + image_memory, mesh->volume_clipping, handle.metadata().transform_3d); } else if (image_memory->data_elements == 3) { - grid = openvdb_grid_from_device_texture<openvdb::Vec3fGrid>(image_memory, - mesh->volume_clipping, - handle.metadata().transform_3d); + grid = openvdb_grid_from_device_texture<openvdb::Vec3fGrid>( + image_memory, mesh->volume_clipping, handle.metadata().transform_3d); } else if (image_memory->data_elements == 4) { - grid = openvdb_grid_from_device_texture<openvdb::Vec4fGrid>(image_memory, - mesh->volume_clipping, - handle.metadata().transform_3d); + grid = openvdb_grid_from_device_texture<openvdb::Vec4fGrid>( + image_memory, mesh->volume_clipping, handle.metadata().transform_3d); } } diff --git a/release/datafiles/locale b/release/datafiles/locale -Subproject 2b3c19f5f61fc72dba56a7edfdc4e55e2327dc1 +Subproject bc6623180aee561cba84ac11f5959b31016612e diff --git a/release/scripts/addons b/release/scripts/addons -Subproject 49c39f59fbc464dd34388990123f271c39eacbf +Subproject 97be901f0772a0e57e2c8c99b9b6336b6be8aec diff --git a/release/scripts/addons_contrib b/release/scripts/addons_contrib -Subproject a52733b58d95ce60ecde95a9eca242e7319c285 +Subproject f2f4a8b3bfa36ee49f7bdb3a1acb40ef4b39ee3 diff --git a/source/blender/python/mathutils/mathutils_bvhtree.c b/source/blender/python/mathutils/mathutils_bvhtree.c index 6a007502d3e..79fa3b829d9 100644 --- a/source/blender/python/mathutils/mathutils_bvhtree.c +++ b/source/blender/python/mathutils/mathutils_bvhtree.c @@ -549,8 +549,7 @@ static bool py_bvhtree_overlap_cb(void *userdata, int index_a, int index_b, int } } - return (isect_tri_tri_v3( - UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1]) && + return (isect_tri_tri_v3(UNPACK3(tri_a_co), UNPACK3(tri_b_co), ix_pair[0], ix_pair[1]) && ((verts_shared == 0) || (len_squared_v3v3(ix_pair[0], ix_pair[1]) > data->epsilon))); } diff --git a/source/tools b/source/tools -Subproject 896c5f78952adb2d091d28c65086d46992dabda +Subproject 6a252de776d0b9dca3167c30a7621a4f1e9bc91 |