diff options
Diffstat (limited to 'intern/cycles/blender')
-rw-r--r-- | intern/cycles/blender/addon/engine.py | 27 | ||||
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 37 | ||||
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 11 | ||||
-rw-r--r-- | intern/cycles/blender/blender_camera.cpp | 17 | ||||
-rw-r--r-- | intern/cycles/blender/blender_id_map.h | 2 | ||||
-rw-r--r-- | intern/cycles/blender/blender_mesh.cpp | 77 | ||||
-rw-r--r-- | intern/cycles/blender/blender_object.cpp | 4 | ||||
-rw-r--r-- | intern/cycles/blender/blender_python.cpp | 1 | ||||
-rw-r--r-- | intern/cycles/blender/blender_session.cpp | 29 | ||||
-rw-r--r-- | intern/cycles/blender/blender_shader.cpp | 7 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.cpp | 71 | ||||
-rw-r--r-- | intern/cycles/blender/blender_sync.h | 2 | ||||
-rw-r--r-- | intern/cycles/blender/blender_util.h | 6 | ||||
-rw-r--r-- | intern/cycles/blender/blender_volume.cpp | 75 |
14 files changed, 226 insertions, 140 deletions
diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py index 7566ca28dd7..67e448db859 100644 --- a/intern/cycles/blender/addon/engine.py +++ b/intern/cycles/blender/addon/engine.py @@ -224,7 +224,7 @@ def system_info(): import _cycles return _cycles.system_info() -def list_render_passes(srl): +def list_render_passes(scene, srl): # Builtin Blender passes. yield ("Combined", "RGBA", 'COLOR') @@ -279,14 +279,17 @@ def list_render_passes(srl): yield ("Denoising Normal", "XYZ", 'VECTOR') yield ("Denoising Albedo", "RGB", 'COLOR') yield ("Denoising Depth", "Z", 'VALUE') - yield ("Denoising Shadowing", "X", 'VALUE') - yield ("Denoising Variance", "RGB", 'COLOR') - yield ("Denoising Intensity", "X", 'VALUE') - clean_options = ("denoising_diffuse_direct", "denoising_diffuse_indirect", - "denoising_glossy_direct", "denoising_glossy_indirect", - "denoising_transmission_direct", "denoising_transmission_indirect") - if any(getattr(crl, option) for option in clean_options): - yield ("Denoising Clean", "RGB", 'COLOR') + + if scene.cycles.denoiser == 'NLM': + yield ("Denoising Shadowing", "X", 'VALUE') + yield ("Denoising Variance", "RGB", 'COLOR') + yield ("Denoising Intensity", "X", 'VALUE') + + clean_options = ("denoising_diffuse_direct", "denoising_diffuse_indirect", + "denoising_glossy_direct", "denoising_glossy_indirect", + "denoising_transmission_direct", "denoising_transmission_indirect") + if any(getattr(crl, option) for option in clean_options): + yield ("Denoising Clean", "RGB", 'COLOR') # Custom AOV passes. for aov in crl.aovs: @@ -298,15 +301,15 @@ def list_render_passes(srl): def register_passes(engine, scene, view_layer): # Detect duplicate render pass names, first one wins. listed = set() - for name, channelids, channeltype in list_render_passes(view_layer): + for name, channelids, channeltype in list_render_passes(scene, view_layer): if name not in listed: engine.register_pass(scene, view_layer, name, len(channelids), channelids, channeltype) listed.add(name) -def detect_conflicting_passes(view_layer): +def detect_conflicting_passes(scene, view_layer): # Detect conflicting render pass names for UI. counter = {} - for name, _, _ in list_render_passes(view_layer): + for name, _, _ in list_render_passes(scene, view_layer): counter[name] = counter.get(name, 0) + 1 for aov in view_layer.cycles.aovs: diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py index da706451f88..45d25720aff 100644 --- a/intern/cycles/blender/addon/properties.py +++ b/intern/cycles/blender/addon/properties.py @@ -182,6 +182,7 @@ enum_aov_types = ( ('COLOR', "Color", "Write a Color pass", 1), ) + def enum_openimagedenoise_denoiser(self, context): if _cycles.with_openimagedenoise: return [('OPENIMAGEDENOISE', "OpenImageDenoise", "Use Intel OpenImageDenoise AI denoiser running on the CPU", 4)] @@ -208,14 +209,23 @@ def enum_preview_denoiser(self, context): def enum_denoiser(self, context): items = [('NLM', "NLM", "Cycles native non-local means denoiser, running on any compute device", 1)] items += enum_optix_denoiser(self, context) + items += enum_openimagedenoise_denoiser(self, context) return items -enum_denoising_optix_input_passes = ( +enum_denoising_input_passes = ( ('RGB', "Color", "Use only color as input", 1), ('RGB_ALBEDO', "Color + Albedo", "Use color and albedo data as input", 2), ('RGB_ALBEDO_NORMAL', "Color + Albedo + Normal", "Use color, albedo and normal data as input", 3), ) + +def update_render_passes(self, context): + scene = context.scene + view_layer = context.view_layer + view_layer.update_render_passes() + engine.detect_conflicting_passes(scene, view_layer) + + class CyclesRenderSettings(bpy.types.PropertyGroup): device: EnumProperty( @@ -261,9 +271,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): denoiser: EnumProperty( name="Denoiser", - description="Denoise the image with the selected denoiser", + description="Denoise the image with the selected denoiser. " + "For denoising the image after rendering, denoising data render passes " + "also adapt to the selected denoiser", items=enum_denoiser, default=1, + update=update_render_passes, ) preview_denoiser: EnumProperty( name="Viewport Denoiser", @@ -818,6 +831,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup): debug_use_cuda_split_kernel: BoolProperty(name="Split Kernel", default=False) debug_optix_cuda_streams: IntProperty(name="CUDA Streams", default=1, min=1) + debug_optix_curves_api: BoolProperty(name="Native OptiX Curve Primitive", default=False) debug_opencl_kernel_type: EnumProperty( name="OpenCL Kernel Type", @@ -1291,12 +1305,6 @@ class CyclesCurveRenderSettings(bpy.types.PropertyGroup): del bpy.types.Scene.cycles_curves -def update_render_passes(self, context): - view_layer = context.view_layer - view_layer.update_render_passes() - engine.detect_conflicting_passes(view_layer) - - class CyclesAOVPass(bpy.types.PropertyGroup): name: StringProperty( name="Name", @@ -1430,7 +1438,7 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup): ) denoising_store_passes: BoolProperty( name="Store Denoising Passes", - description="Store the denoising feature passes and the noisy image", + description="Store the denoising feature passes and the noisy image. The passes adapt to the denoiser selected for rendering", default=False, update=update_render_passes, ) @@ -1443,11 +1451,18 @@ class CyclesRenderLayerSettings(bpy.types.PropertyGroup): denoising_optix_input_passes: EnumProperty( name="Input Passes", - description="Passes handed over to the OptiX denoiser (this can have different effects on the denoised image)", - items=enum_denoising_optix_input_passes, + description="Passes used by the denoiser to distinguish noise from shader and geometry detail", + items=enum_denoising_input_passes, default='RGB_ALBEDO', ) + denoising_openimagedenoise_input_passes: EnumProperty( + name="Input Passes", + description="Passes used by the denoiser to distinguish noise from shader and geometry detail", + items=enum_denoising_input_passes, + default='RGB_ALBEDO_NORMAL', + ) + use_pass_crypto_object: BoolProperty( name="Cryptomatte Object", description="Render cryptomatte object pass, for isolating objects in compositing", diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py index 129f16b0357..03b1675c309 100644 --- a/intern/cycles/blender/addon/ui.py +++ b/intern/cycles/blender/addon/ui.py @@ -265,7 +265,12 @@ class CYCLES_RENDER_PT_sampling_denoising(CyclesButtonsPanel, Panel): row = heading.row(align=True) row.prop(cscene, "use_denoising", text="") sub = row.row() + sub.active = cscene.use_denoising + for view_layer in scene.view_layers: + if view_layer.cycles.denoising_store_passes: + sub.active = True + sub.prop(cscene, "denoiser", text="") heading = layout.column(align=False, heading="Viewport") @@ -777,10 +782,6 @@ class CYCLES_RENDER_PT_filter(CyclesButtonsPanel, Panel): col.prop(view_layer, "use_solid", text="Surfaces") col.prop(view_layer, "use_strand", text="Hair") col.prop(view_layer, "use_volumes", text="Volumes") - if with_freestyle: - sub = col.row(align=True) - sub.prop(view_layer, "use_freestyle", text="Freestyle") - sub.active = rd.use_freestyle class CYCLES_RENDER_PT_override(CyclesButtonsPanel, Panel): @@ -1007,6 +1008,7 @@ class CYCLES_RENDER_PT_denoising(CyclesButtonsPanel, Panel): col.prop(cycles_view_layer, "denoising_optix_input_passes") return elif denoiser == 'OPENIMAGEDENOISE': + col.prop(cycles_view_layer, "denoising_openimagedenoise_input_passes") return col.prop(cycles_view_layer, "denoising_radius", text="Radius") @@ -2026,6 +2028,7 @@ class CYCLES_RENDER_PT_debug(CyclesButtonsPanel, Panel): col = layout.column() col.label(text="OptiX Flags:") col.prop(cscene, "debug_optix_cuda_streams") + col.prop(cscene, "debug_optix_curves_api") col.separator() diff --git a/intern/cycles/blender/blender_camera.cpp b/intern/cycles/blender/blender_camera.cpp index 011678a7a65..e1ab3b3fbc1 100644 --- a/intern/cycles/blender/blender_camera.cpp +++ b/intern/cycles/blender/blender_camera.cpp @@ -76,6 +76,9 @@ struct BlenderCamera { int full_width; int full_height; + int render_width; + int render_height; + BoundBox2D border; BoundBox2D pano_viewplane; BoundBox2D viewport_camera_border; @@ -126,8 +129,10 @@ static void blender_camera_init(BlenderCamera *bcam, BL::RenderSettings &b_rende bcam->matrix = transform_identity(); /* render resolution */ - bcam->full_width = render_resolution_x(b_render); - bcam->full_height = render_resolution_y(b_render); + bcam->render_width = render_resolution_x(b_render); + bcam->render_height = render_resolution_y(b_render); + bcam->full_width = bcam->render_width; + bcam->full_height = bcam->render_height; } static float blender_camera_focal_distance(BL::RenderEngine &b_engine, @@ -398,8 +403,8 @@ static void blender_camera_sync(Camera *cam, /* panorama sensor */ if (bcam->type == CAMERA_PANORAMA && bcam->panorama_type == PANORAMA_FISHEYE_EQUISOLID) { - float fit_xratio = (float)bcam->full_width * bcam->pixelaspect.x; - float fit_yratio = (float)bcam->full_height * bcam->pixelaspect.y; + float fit_xratio = (float)bcam->render_width * bcam->pixelaspect.x; + float fit_yratio = (float)bcam->render_height * bcam->pixelaspect.y; bool horizontal_fit; float sensor_size; @@ -709,6 +714,10 @@ static void blender_camera_from_view(BlenderCamera *bcam, /* 3d view transform */ bcam->matrix = transform_inverse(get_transform(b_rv3d.view_matrix())); + + /* dimensions */ + bcam->full_width = width; + bcam->full_height = height; } static void blender_camera_view_subset(BL::RenderEngine &b_engine, diff --git a/intern/cycles/blender/blender_id_map.h b/intern/cycles/blender/blender_id_map.h index 3bc42e349ae..b5f6aaa67a8 100644 --- a/intern/cycles/blender/blender_id_map.h +++ b/intern/cycles/blender/blender_id_map.h @@ -200,7 +200,7 @@ template<typename K, typename T> class id_map { * To uniquely identify instances, we use the parent, object and persistent instance ID. * We also export separate object for a mesh and its particle hair. */ -enum { OBJECT_PERSISTENT_ID_SIZE = 16 }; +enum { OBJECT_PERSISTENT_ID_SIZE = 8 /* MAX_DUPLI_RECUR in Blender. */ }; struct ObjectKey { void *parent; diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp index 49407799fcd..f4354d5166e 100644 --- a/intern/cycles/blender/blender_mesh.cpp +++ b/intern/cycles/blender/blender_mesh.cpp @@ -923,6 +923,74 @@ static void create_subd_mesh(Scene *scene, /* Sync */ +static BL::MeshSequenceCacheModifier object_mesh_cache_find(BL::Object &b_ob, + BL::Scene /*b_scene*/) +{ + BL::Object::modifiers_iterator b_mod; + + for (b_ob.modifiers.begin(b_mod); b_mod != b_ob.modifiers.end(); ++b_mod) { + if (!b_mod->is_a(&RNA_MeshSequenceCacheModifier)) { + continue; + } + + BL::MeshSequenceCacheModifier mesh_cache = BL::MeshSequenceCacheModifier(*b_mod); + + if (MeshSequenceCacheModifier_has_velocity_get(&mesh_cache.ptr)) { + return mesh_cache; + } + } + + return BL::MeshSequenceCacheModifier(PointerRNA_NULL); +} + +static void sync_mesh_cached_velocities(BL::Object &b_ob, + BL::Scene b_scene, + Scene *scene, + Mesh *mesh) +{ + if (scene->need_motion() == Scene::MOTION_NONE) + return; + + BL::MeshSequenceCacheModifier b_mesh_cache = object_mesh_cache_find(b_ob, b_scene); + + if (!b_mesh_cache) { + return; + } + + /* Find or add attribute */ + float3 *P = &mesh->verts[0]; + Attribute *attr_mP = mesh->attributes.find(ATTR_STD_MOTION_VERTEX_POSITION); + + if (!attr_mP) { + attr_mP = mesh->attributes.add(ATTR_STD_MOTION_VERTEX_POSITION); + } + + if (!MeshSequenceCacheModifier_read_velocity_get(&b_mesh_cache.ptr)) { + return; + } + + const size_t numverts = mesh->verts.size(); + + if (b_mesh_cache.vertex_velocities.length() != numverts) { + return; + } + + /* Only export previous and next frame, we don't have any in between data. */ + float motion_times[2] = {-1.0f, 1.0f}; + for (int step = 0; step < 2; step++) { + const float relative_time = motion_times[step] * scene->motion_shutter_time() * 0.5f; + float3 *mP = attr_mP->data_float3() + step * numverts; + + BL::MeshSequenceCacheModifier::vertex_velocities_iterator vvi; + int i = 0; + + for (b_mesh_cache.vertex_velocities.begin(vvi); vvi != b_mesh_cache.vertex_velocities.end(); + ++vvi, ++i) { + mP[i] = P[i] + get_float3(vvi->velocity()) * relative_time; + } + } +} + static void sync_mesh_fluid_motion(BL::Object &b_ob, Scene *scene, Mesh *mesh) { if (scene->need_motion() == Scene::MOTION_NONE) @@ -1002,6 +1070,9 @@ void BlenderSync::sync_mesh(BL::Depsgraph b_depsgraph, } } + /* cached velocities (e.g. from alembic archive) */ + sync_mesh_cached_velocities(b_ob, b_depsgraph.scene(), scene, mesh); + /* mesh fluid motion mantaflow */ sync_mesh_fluid_motion(b_ob, scene, mesh); @@ -1023,6 +1094,12 @@ void BlenderSync::sync_mesh_motion(BL::Depsgraph b_depsgraph, return; } + /* Cached motion blur already exported. */ + BL::MeshSequenceCacheModifier mesh_cache = object_mesh_cache_find(b_ob, b_scene); + if (mesh_cache) { + return; + } + /* Skip if no vertices were exported. */ size_t numverts = mesh->verts.size(); if (numverts == 0) { diff --git a/intern/cycles/blender/blender_object.cpp b/intern/cycles/blender/blender_object.cpp index d3a37563ef4..3ea6892a349 100644 --- a/intern/cycles/blender/blender_object.cpp +++ b/intern/cycles/blender/blender_object.cpp @@ -59,7 +59,7 @@ bool BlenderSync::BKE_object_is_modified(BL::Object &b_ob) return false; } -bool BlenderSync::object_is_mesh(BL::Object &b_ob) +bool BlenderSync::object_is_geometry(BL::Object &b_ob) { BL::ID b_ob_data = b_ob.data(); @@ -143,7 +143,7 @@ Object *BlenderSync::sync_object(BL::Depsgraph &b_depsgraph, } /* only interested in object that we can create meshes from */ - if (!object_is_mesh(b_ob)) { + if (!object_is_geometry(b_ob)) { return NULL; } diff --git a/intern/cycles/blender/blender_python.cpp b/intern/cycles/blender/blender_python.cpp index 3e595c3ee52..25c77b74ce3 100644 --- a/intern/cycles/blender/blender_python.cpp +++ b/intern/cycles/blender/blender_python.cpp @@ -92,6 +92,7 @@ bool debug_flags_sync_from_scene(BL::Scene b_scene) flags.cuda.split_kernel = get_boolean(cscene, "debug_use_cuda_split_kernel"); /* Synchronize OptiX flags. */ flags.optix.cuda_streams = get_int(cscene, "debug_optix_cuda_streams"); + flags.optix.curves_api = get_boolean(cscene, "debug_optix_curves_api"); /* Synchronize OpenCL device type. */ switch (get_enum(cscene, "debug_opencl_device_type")) { case 0: diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 391a1b8f473..a06030c8b7d 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -59,6 +59,7 @@ BlenderSession::BlenderSession(BL::RenderEngine &b_engine, BL::BlendData &b_data, bool preview_osl) : session(NULL), + scene(NULL), sync(NULL), b_engine(b_engine), b_userpref(b_userpref), @@ -88,6 +89,7 @@ BlenderSession::BlenderSession(BL::RenderEngine &b_engine, int width, int height) : session(NULL), + scene(NULL), sync(NULL), b_engine(b_engine), b_userpref(b_userpref), @@ -492,27 +494,15 @@ void BlenderSession::render(BL::Depsgraph &b_depsgraph_) /* Update denoising parameters. */ session->set_denoising(session_params.denoising); - bool use_denoising = session_params.denoising.use; - bool store_denoising_passes = session_params.denoising.store_passes; - - buffer_params.denoising_data_pass = use_denoising || store_denoising_passes; - buffer_params.denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES); - buffer_params.denoising_prefiltered_pass = store_denoising_passes && - session_params.denoising.type == DENOISER_NLM; - - scene->film->denoising_data_pass = buffer_params.denoising_data_pass; - scene->film->denoising_clean_pass = buffer_params.denoising_clean_pass; - scene->film->denoising_prefiltered_pass = buffer_params.denoising_prefiltered_pass; - - /* Add passes */ + /* Compute render passes and film settings. */ vector<Pass> passes = sync->sync_render_passes( b_rlay, b_view_layer, session_params.adaptive_sampling, session_params.denoising); - buffer_params.passes = passes; - scene->film->pass_alpha_threshold = b_view_layer.pass_alpha_threshold(); - scene->film->tag_passes_update(scene, passes); - scene->film->tag_update(scene); - scene->integrator->tag_update(scene); + /* Set buffer params, using film settings from sync_render_passes. */ + buffer_params.passes = passes; + buffer_params.denoising_data_pass = scene->film->denoising_data_pass; + buffer_params.denoising_clean_pass = scene->film->denoising_clean_pass; + buffer_params.denoising_prefiltered_pass = scene->film->denoising_prefiltered_pass; BL::RenderResult::views_iterator b_view_iter; @@ -982,7 +972,8 @@ void BlenderSession::update_status_progress() remaining_time = (1.0 - (double)progress) * (render_time / (double)progress); if (background) { - scene_status += " | " + scene->name; + if (scene) + scene_status += " | " + scene->name; if (b_rlay_name != "") scene_status += ", " + b_rlay_name; diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp index 19d2730dc93..ae681432a43 100644 --- a/intern/cycles/blender/blender_shader.cpp +++ b/intern/cycles/blender/blender_shader.cpp @@ -678,7 +678,7 @@ static ShaderNode *add_node(Scene *scene, * builtin names for packed images and movies */ int scene_frame = b_scene.frame_current(); - int image_frame = image_user_frame_number(b_image_user, scene_frame); + int image_frame = image_user_frame_number(b_image_user, b_image, scene_frame); image->handle = scene->image_manager->add_image( new BlenderImageLoader(b_image, image_frame), image->image_params()); } @@ -713,7 +713,7 @@ static ShaderNode *add_node(Scene *scene, if (is_builtin) { int scene_frame = b_scene.frame_current(); - int image_frame = image_user_frame_number(b_image_user, scene_frame); + int image_frame = image_user_frame_number(b_image_user, b_image, scene_frame); env->handle = scene->image_manager->add_image(new BlenderImageLoader(b_image, image_frame), env->image_params()); } @@ -815,9 +815,10 @@ static ShaderNode *add_node(Scene *scene, sky->ground_albedo = b_sky_node.ground_albedo(); sky->sun_disc = b_sky_node.sun_disc(); sky->sun_size = b_sky_node.sun_size(); + sky->sun_intensity = b_sky_node.sun_intensity(); sky->sun_elevation = b_sky_node.sun_elevation(); sky->sun_rotation = b_sky_node.sun_rotation(); - sky->altitude = b_sky_node.altitude(); + sky->altitude = 1000.0f * b_sky_node.altitude(); sky->air_density = b_sky_node.air_density(); sky->dust_density = b_sky_node.dust_density(); sky->ozone_density = b_sky_node.ozone_density(); diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index bf065cc5492..511061db08a 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -147,30 +147,43 @@ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d /* Object */ else if (b_id.is_a(&RNA_Object)) { BL::Object b_ob(b_id); - const bool updated_geometry = b_update->is_updated_geometry(); + const bool is_geometry = object_is_geometry(b_ob); + const bool is_light = !is_geometry && object_is_light(b_ob); - if (b_update->is_updated_transform() || b_update->is_updated_shading()) { - object_map.set_recalc(b_ob); - light_map.set_recalc(b_ob); - } + if (is_geometry || is_light) { + const bool updated_geometry = b_update->is_updated_geometry(); - if (object_is_mesh(b_ob)) { - if (updated_geometry || - (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { - BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data(); - geometry_map.set_recalc(key); - } - } - else if (object_is_light(b_ob)) { - if (updated_geometry) { - light_map.set_recalc(b_ob); + /* Geometry (mesh, hair, volume). */ + if (is_geometry) { + if (b_update->is_updated_transform() || b_update->is_updated_shading()) { + object_map.set_recalc(b_ob); + } + + if (updated_geometry || + (object_subdivision_type(b_ob, preview, experimental) != Mesh::SUBDIVISION_NONE)) { + BL::ID key = BKE_object_is_modified(b_ob) ? b_ob : b_ob.data(); + geometry_map.set_recalc(key); + } + + if (updated_geometry) { + BL::Object::particle_systems_iterator b_psys; + for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); + ++b_psys) { + particle_system_map.set_recalc(b_ob); + } + } } - } + /* Light */ + else if (is_light) { + if (b_update->is_updated_transform() || b_update->is_updated_shading()) { + object_map.set_recalc(b_ob); + light_map.set_recalc(b_ob); + } - if (updated_geometry) { - BL::Object::particle_systems_iterator b_psys; - for (b_ob.particle_systems.begin(b_psys); b_psys != b_ob.particle_systems.end(); ++b_psys) - particle_system_map.set_recalc(b_ob); + if (updated_geometry) { + light_map.set_recalc(b_ob); + } + } } } /* Mesh */ @@ -684,6 +697,16 @@ vector<Pass> BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, } RNA_END; + scene->film->denoising_data_pass = denoising.use || denoising.store_passes; + scene->film->denoising_clean_pass = (scene->film->denoising_flags & DENOISING_CLEAN_ALL_PASSES); + scene->film->denoising_prefiltered_pass = denoising.store_passes && + denoising.type == DENOISER_NLM; + + scene->film->pass_alpha_threshold = b_view_layer.pass_alpha_threshold(); + scene->film->tag_passes_update(scene, passes); + scene->film->tag_update(scene); + scene->integrator->tag_update(scene); + return passes; } @@ -941,7 +964,13 @@ DenoiseParams BlenderSync::get_denoise_params(BL::Scene &b_scene, denoising.strength = get_float(clayer, "denoising_strength"); denoising.feature_strength = get_float(clayer, "denoising_feature_strength"); denoising.relative_pca = get_boolean(clayer, "denoising_relative_pca"); - denoising.optix_input_passes = get_enum(clayer, "denoising_optix_input_passes"); + + denoising.input_passes = (DenoiserInput)get_enum( + clayer, + (denoising.type == DENOISER_OPTIX) ? "denoising_optix_input_passes" : + "denoising_openimagedenoise_input_passes", + DENOISER_INPUT_NUM, + DENOISER_INPUT_RGB_ALBEDO_NORMAL); denoising.store_passes = get_boolean(clayer, "denoising_store_passes"); } diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 0214d9eb3b8..a551ec31e04 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -208,7 +208,7 @@ class BlenderSync { /* util */ void find_shader(BL::ID &id, vector<Shader *> &used_shaders, Shader *default_shader); bool BKE_object_is_modified(BL::Object &b_ob); - bool object_is_mesh(BL::Object &b_ob); + bool object_is_geometry(BL::Object &b_ob); bool object_is_light(BL::Object &b_ob); /* variables */ diff --git a/intern/cycles/blender/blender_util.h b/intern/cycles/blender/blender_util.h index ad90a5f8d52..1ea34b41aa2 100644 --- a/intern/cycles/blender/blender_util.h +++ b/intern/cycles/blender/blender_util.h @@ -238,7 +238,7 @@ static inline string image_user_file_path(BL::ImageUser &iuser, { char filepath[1024]; iuser.tile(0); - BKE_image_user_frame_calc(NULL, iuser.ptr.data, cfra); + BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra); BKE_image_user_file_path(iuser.ptr.data, ima.ptr.data, filepath); string filepath_str = string(filepath); @@ -248,9 +248,9 @@ static inline string image_user_file_path(BL::ImageUser &iuser, return filepath_str; } -static inline int image_user_frame_number(BL::ImageUser &iuser, int cfra) +static inline int image_user_frame_number(BL::ImageUser &iuser, BL::Image &ima, int cfra) { - BKE_image_user_frame_calc(NULL, iuser.ptr.data, cfra); + BKE_image_user_frame_calc(ima.ptr.data, iuser.ptr.data, cfra); return iuser.frame_current(); } diff --git a/intern/cycles/blender/blender_volume.cpp b/intern/cycles/blender/blender_volume.cpp index 80591e0eec8..d0e1e4d6131 100644 --- a/intern/cycles/blender/blender_volume.cpp +++ b/intern/cycles/blender/blender_volume.cpp @@ -217,43 +217,29 @@ static void sync_smoke_volume(Scene *scene, BL::Object &b_ob, Mesh *mesh, float class BlenderVolumeLoader : public VDBImageLoader { public: BlenderVolumeLoader(BL::BlendData &b_data, BL::Volume &b_volume, const string &grid_name) - : VDBImageLoader(grid_name), b_data(b_data), b_volume(b_volume), unload(false) - { - } - - bool load_metadata(ImageMetaData &metadata) override + : VDBImageLoader(grid_name), b_volume(b_volume) { b_volume.grids.load(b_data.ptr.data); - BL::VolumeGrid b_volume_grid = find_grid(); - - if (!b_volume_grid) { - return false; - } - - unload = !b_volume_grid.is_loaded(); #ifdef WITH_OPENVDB - Volume *volume = (Volume *)b_volume.ptr.data; - VolumeGrid *volume_grid = (VolumeGrid *)b_volume_grid.ptr.data; - grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid); -#endif + BL::Volume::grids_iterator b_grid_iter; + for (b_volume.grids.begin(b_grid_iter); b_grid_iter != b_volume.grids.end(); ++b_grid_iter) { + BL::VolumeGrid b_volume_grid(*b_grid_iter); + if (b_volume_grid.name() == grid_name) { + const bool unload = !b_volume_grid.is_loaded(); - return VDBImageLoader::load_metadata(metadata); - } + Volume *volume = (Volume *)b_volume.ptr.data; + VolumeGrid *volume_grid = (VolumeGrid *)b_volume_grid.ptr.data; + grid = BKE_volume_grid_openvdb_for_read(volume, volume_grid); - bool load_pixels(const ImageMetaData &metadata, - void *pixels, - const size_t pixel_size, - const bool associate_alpha) override - { - b_volume.grids.load(b_data.ptr.data); - BL::VolumeGrid b_volume_grid = find_grid(); + if (unload) { + b_volume_grid.unload(); + } - if (!b_volume_grid) { - return false; + break; + } } - - return VDBImageLoader::load_pixels(metadata, pixels, pixel_size, associate_alpha); +#endif } bool equals(const ImageLoader &other) const override @@ -263,36 +249,7 @@ class BlenderVolumeLoader : public VDBImageLoader { return b_volume == other_loader.b_volume && grid_name == other_loader.grid_name; } - void cleanup() override - { - VDBImageLoader::cleanup(); - - BL::VolumeGrid b_volume_grid = find_grid(); - if (b_volume_grid && unload) { - b_volume_grid.unload(); - } - } - - /* Find grid with matching name. Grid point not stored in the class since - * grids may be unloaded before we load the pixels, for example for motion - * blur where we move between frames. */ - BL::VolumeGrid find_grid() - { -#ifdef WITH_OPENVDB - BL::Volume::grids_iterator b_grid_iter; - for (b_volume.grids.begin(b_grid_iter); b_grid_iter != b_volume.grids.end(); ++b_grid_iter) { - if (b_grid_iter->name() == grid_name) { - return *b_grid_iter; - } - } -#endif - - return BL::VolumeGrid(PointerRNA_NULL); - } - - BL::BlendData b_data; BL::Volume b_volume; - bool unload; }; static void sync_volume_object(BL::BlendData &b_data, BL::Object &b_ob, Scene *scene, Mesh *mesh) @@ -342,7 +299,7 @@ static void sync_volume_object(BL::BlendData &b_data, BL::Object &b_ob, Scene *s ImageParams params; params.frame = b_volume.grids.frame(); - attr->data_voxel() = scene->image_manager->add_image(loader, params); + attr->data_voxel() = scene->image_manager->add_image(loader, params, false); } } } |