From bc3139d79226896cf6c2b0813a1188eda70fad09 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 17 May 2019 16:57:31 +0200 Subject: Cycles/Eevee: unify depth of field settings for cameras There is now a checkbox to enable/disable depth of field per camera. For Eevee this replace the scene level setting. For Cycles there is now only an F-Stop value, no longer a Radius. Existing files are converted based on Cycles or Eevee being set in the scene. Differential Revision: https://developer.blender.org/D4882 --- source/blender/alembic/intern/abc_camera.cc | 16 +- source/blender/blenkernel/BKE_blender_version.h | 2 +- source/blender/blenkernel/BKE_camera.h | 2 - source/blender/blenkernel/intern/camera.c | 23 +-- source/blender/blenkernel/intern/library_query.c | 2 +- source/blender/blenloader/intern/readfile.c | 5 +- source/blender/blenloader/intern/versioning_280.c | 28 +++- .../blender/blenloader/intern/versioning_cycles.c | 58 ++++++- .../intern/builder/deg_builder_relations.cc | 4 +- .../draw/engines/eevee/eevee_depth_of_field.c | 173 ++++++++++----------- .../draw/engines/gpencil/gpencil_shader_fx.c | 2 +- .../draw/engines/workbench/workbench_effect_dof.c | 13 +- source/blender/editors/include/ED_view3d.h | 1 - source/blender/editors/space_view3d/view3d_draw.c | 7 - .../editors/space_view3d/view3d_gizmo_camera.c | 6 +- source/blender/makesdna/DNA_camera_types.h | 25 ++- source/blender/makesdna/DNA_scene_types.h | 2 +- source/blender/makesdna/intern/makesdna.c | 2 + source/blender/makesrna/RNA_access.h | 1 + source/blender/makesrna/intern/rna_camera.c | 115 ++++++++++++-- source/blender/makesrna/intern/rna_scene.c | 114 -------------- source/blender/python/gpu/gpu_py_offscreen.c | 1 - 22 files changed, 325 insertions(+), 277 deletions(-) (limited to 'source/blender') diff --git a/source/blender/alembic/intern/abc_camera.cc b/source/blender/alembic/intern/abc_camera.cc index b15608703de..dc7f00b63d9 100644 --- a/source/blender/alembic/intern/abc_camera.cc +++ b/source/blender/alembic/intern/abc_camera.cc @@ -80,19 +80,19 @@ void AbcCameraWriter::do_write() m_camera_sample.setNearClippingPlane(cam->clip_start); m_camera_sample.setFarClippingPlane(cam->clip_end); - if (cam->dof_ob) { - Imath::V3f v(m_object->loc[0] - cam->dof_ob->loc[0], - m_object->loc[1] - cam->dof_ob->loc[1], - m_object->loc[2] - cam->dof_ob->loc[2]); + if (cam->dof.focus_object) { + Imath::V3f v(m_object->loc[0] - cam->dof.focus_object->loc[0], + m_object->loc[1] - cam->dof.focus_object->loc[1], + m_object->loc[2] - cam->dof.focus_object->loc[2]); m_camera_sample.setFocusDistance(v.length()); } else { - m_camera_sample.setFocusDistance(cam->gpu_dof.focus_distance); + m_camera_sample.setFocusDistance(cam->dof.focus_distance); } /* Blender camera does not have an fstop param, so try to find a custom prop * instead. */ - m_camera_sample.setFStop(cam->gpu_dof.fstop); + m_camera_sample.setFStop(cam->dof.aperture_fstop); m_camera_sample.setLensSqueezeRatio(1.0); m_camera_schema.set(m_camera_sample); @@ -166,8 +166,8 @@ void AbcCameraReader::readObjectData(Main *bmain, const ISampleSelector &sample_ bcam->shifty = v_film_offset / apperture_y / film_aspect; bcam->clip_start = max_ff(0.1f, static_cast(cam_sample.getNearClippingPlane())); bcam->clip_end = static_cast(cam_sample.getFarClippingPlane()); - bcam->gpu_dof.focus_distance = static_cast(cam_sample.getFocusDistance()); - bcam->gpu_dof.fstop = static_cast(cam_sample.getFStop()); + bcam->dof.focus_distance = static_cast(cam_sample.getFocusDistance()); + bcam->dof.aperture_fstop = static_cast(cam_sample.getFStop()); m_object = BKE_object_add_only_object(bmain, OB_CAMERA, m_object_name.c_str()); m_object->data = bcam; diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h index 0afcd37c81b..5d659d63e27 100644 --- a/source/blender/blenkernel/BKE_blender_version.h +++ b/source/blender/blenkernel/BKE_blender_version.h @@ -27,7 +27,7 @@ * \note Use #STRINGIFY() rather than defining with quotes. */ #define BLENDER_VERSION 280 -#define BLENDER_SUBVERSION 68 +#define BLENDER_SUBVERSION 69 /** Several breakages with 280, e.g. collections vs layers. */ #define BLENDER_MINVERSION 280 #define BLENDER_MINSUBVERSION 0 diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index 10cd129fbf9..caed4959eff 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -139,8 +139,6 @@ bool BKE_camera_view_frame_fit_to_coords(const struct Depsgraph *depsgraph, float r_co[3], float *r_scale); -void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings); - /* Camera multi-view API */ struct Object *BKE_camera_multiview_render(struct Scene *scene, diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 25399d342e1..a17cbb29550 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -66,8 +66,9 @@ void BKE_camera_init(Camera *cam) cam->flag |= CAM_SHOWPASSEPARTOUT; cam->passepartalpha = 0.5f; - cam->gpu_dof.fstop = 128.0f; - cam->gpu_dof.ratio = 1.0f; + cam->dof.aperture_fstop = 5.6f; + cam->dof.aperture_ratio = 1.0f; + cam->dof.focus_distance = 10.0f; /* stereoscopy 3d */ cam->stereo.interocular_distance = 0.065f; @@ -134,13 +135,13 @@ float BKE_camera_object_dof_distance(Object *ob) if (ob->type != OB_CAMERA) { return 0.0f; } - if (cam->dof_ob) { + if (cam->dof.focus_object) { float view_dir[3], dof_dir[3]; normalize_v3_v3(view_dir, ob->obmat[2]); - sub_v3_v3v3(dof_dir, ob->obmat[3], cam->dof_ob->obmat[3]); + sub_v3_v3v3(dof_dir, ob->obmat[3], cam->dof.focus_object->obmat[3]); return fabsf(dot_v3v3(view_dir, dof_dir)); } - return cam->dof_distance; + return cam->dof.focus_distance; } float BKE_camera_sensor_size(int sensor_fit, float sensor_x, float sensor_y) @@ -1016,18 +1017,6 @@ void BKE_camera_multiview_params(RenderData *rd, } } -void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings) -{ - if (camera->type == OB_CAMERA) { - Camera *cam = camera->data; - r_fx_settings->dof = &cam->gpu_dof; - r_fx_settings->dof->focal_length = cam->lens; - r_fx_settings->dof->sensor = BKE_camera_sensor_size( - cam->sensor_fit, cam->sensor_x, cam->sensor_y); - r_fx_settings->dof->focus_distance = BKE_camera_object_dof_distance(camera); - } -} - CameraBGImage *BKE_camera_background_image_new(Camera *cam) { CameraBGImage *bgpic = MEM_callocN(sizeof(CameraBGImage), "Background Image"); diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c index d0515d8783d..a95069a2af9 100644 --- a/source/blender/blenkernel/intern/library_query.c +++ b/source/blender/blenkernel/intern/library_query.c @@ -755,7 +755,7 @@ static void library_foreach_ID_link(Main *bmain, case ID_CA: { Camera *camera = (Camera *)id; - CALLBACK_INVOKE(camera->dof_ob, IDWALK_CB_NOP); + CALLBACK_INVOKE(camera->dof.focus_object, IDWALK_CB_NOP); for (CameraBGImage *bgpic = camera->bg_images.first; bgpic; bgpic = bgpic->next) { if (bgpic->source == CAM_BGIMG_SOURCE_IMAGE) { CALLBACK_INVOKE(bgpic->ima, IDWALK_CB_USER); diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c index 15749cf5d9b..77deb8658cd 100644 --- a/source/blender/blenloader/intern/readfile.c +++ b/source/blender/blenloader/intern/readfile.c @@ -3882,9 +3882,10 @@ static void lib_link_camera(FileData *fd, Main *main) IDP_LibLinkProperty(ca->id.properties, fd); lib_link_animdata(fd, &ca->id, ca->adt); - ca->ipo = newlibadr_us(fd, ca->id.lib, ca->ipo); // XXX deprecated - old animation system + ca->ipo = newlibadr_us(fd, ca->id.lib, ca->ipo); /* deprecated, for versioning */ - ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); + ca->dof_ob = newlibadr(fd, ca->id.lib, ca->dof_ob); /* deprecated, for versioning */ + ca->dof.focus_object = newlibadr(fd, ca->id.lib, ca->dof.focus_object); for (CameraBGImage *bgpic = ca->bg_images.first; bgpic; bgpic = bgpic->next) { bgpic->ima = newlibadr_us(fd, ca->id.lib, bgpic->ima); diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index e55687da400..23e8aba8c7b 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -1670,7 +1670,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) } \ } \ ((void)0) - + const int SCE_EEVEE_DOF_ENABLED = (1 << 7); IDProperty *props = IDP_GetPropertyFromGroup(scene->layer_properties, RE_engine_id_BLENDER_EEVEE); // EEVEE_GET_BOOL(props, volumetric_enable, SCE_EEVEE_VOLUMETRIC_ENABLED); @@ -3423,5 +3423,31 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) light->sun_angle = 2.0f * atanf(light->area_size); } } + + /* Unify DOF settings (EEVEE part only) */ + if (!DNA_struct_elem_find(fd->filesdna, "Camera", "CameraDOFSettings", "dof")) { + const int SCE_EEVEE_DOF_ENABLED = (1 << 7); + LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) { + if (STREQ(scene->r.engine, RE_engine_id_BLENDER_EEVEE)) { + if (scene->eevee.flag & SCE_EEVEE_DOF_ENABLED) { + Object *cam_ob = scene->camera; + if (cam_ob && cam_ob->type == OB_CAMERA) { + Camera *cam = cam_ob->data; + cam->dof.flag |= CAM_DOF_ENABLED; + } + } + } + } + + LISTBASE_FOREACH (Camera *, camera, &bmain->cameras) { + camera->dof.focus_object = camera->dof_ob; + camera->dof.focus_distance = camera->dof_distance; + camera->dof.aperture_fstop = camera->gpu_dof.fstop; + camera->dof.aperture_rotation = camera->gpu_dof.rotation; + camera->dof.aperture_ratio = camera->gpu_dof.ratio; + camera->dof.aperture_blades = camera->gpu_dof.num_blades; + camera->dof_ob = NULL; + } + } } } diff --git a/source/blender/blenloader/intern/versioning_cycles.c b/source/blender/blenloader/intern/versioning_cycles.c index 3fc6d982e0f..81a2dd8e0ce 100644 --- a/source/blender/blenloader/intern/versioning_cycles.c +++ b/source/blender/blenloader/intern/versioning_cycles.c @@ -32,6 +32,7 @@ #include "DNA_light_types.h" #include "DNA_node_types.h" #include "DNA_particle_types.h" +#include "DNA_camera_types.h" #include "BKE_colortools.h" #include "BKE_idprop.h" @@ -67,12 +68,26 @@ static float cycles_property_float(IDProperty *idprop, const char *name, float d return (prop) ? IDP_Float(prop) : default_value; } +static float cycles_property_int(IDProperty *idprop, const char *name, int default_value) +{ + IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT); + return (prop) ? IDP_Int(prop) : default_value; +} + static bool cycles_property_boolean(IDProperty *idprop, const char *name, bool default_value) { IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_INT); return (prop) ? IDP_Int(prop) : default_value; } +static const char *cycles_property_string(IDProperty *idprop, + const char *name, + const char *default_value) +{ + IDProperty *prop = IDP_GetPropertyTypeFromGroup(idprop, name, IDP_STRING); + return (prop) ? IDP_String(prop) : default_value; +} + static void displacement_node_insert(bNodeTree *ntree) { bool need_update = false; @@ -398,7 +413,7 @@ void blo_do_versions_cycles(FileData *UNUSED(fd), Library *UNUSED(lib), Main *bm } if (!MAIN_VERSION_ATLEAST(bmain, 280, 68)) { - /* Unify Cycles and EEVEE Film Transparency. */ + /* Unify Cycles and Eevee film transparency. */ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { if (STREQ(scene->r.engine, RE_engine_id_CYCLES)) { IDProperty *cscene = cycles_properties_from_ID(&scene->id); @@ -410,6 +425,47 @@ void blo_do_versions_cycles(FileData *UNUSED(fd), Library *UNUSED(lib), Main *bm } } } + + if (!MAIN_VERSION_ATLEAST(bmain, 280, 69)) { + /* Unify Cycles and Eevee depth of field. */ + Scene *scene = bmain->scenes.first; + const char *engine = (scene) ? scene->r.engine : "CYCLES"; + + if (STREQ(engine, RE_engine_id_CYCLES)) { + for (Camera *camera = bmain->cameras.first; camera; camera = camera->id.next) { + IDProperty *ccamera = cycles_properties_from_ID(&camera->id); + if (ccamera) { + const char *aperture_type = cycles_property_string(ccamera, "aperture_type", "RADIUS"); + + camera->dof.aperture_fstop = cycles_property_float(ccamera, "aperture_fstop", 5.6f); + camera->dof.aperture_blades = cycles_property_int(ccamera, "aperture_blades", 0); + camera->dof.aperture_rotation = cycles_property_float(ccamera, "aperture_rotation", 0.0); + camera->dof.aperture_ratio = cycles_property_float(ccamera, "aperture_ratio", 1.0f); + camera->dof.flag |= CAM_DOF_ENABLED; + + float aperture_size = cycles_property_float(ccamera, "aperture_size", 0.0f); + + if (STREQ(aperture_type, "RADIUS") && aperture_size > 0.0f) { + if (camera->type == CAM_ORTHO) { + camera->dof.aperture_fstop = 1.0f / (2.0f * aperture_size); + } + else { + camera->dof.aperture_fstop = (camera->lens * 1e-3f) / (2.0f * aperture_size); + } + + continue; + } + } + + /* No depth of field, set default settings. */ + camera->dof.aperture_fstop = 5.6f; + camera->dof.aperture_blades = 0; + camera->dof.aperture_rotation = 0.0f; + camera->dof.aperture_ratio = 1.0f; + camera->dof.flag &= ~CAM_DOF_ENABLED; + } + } + } } void do_versions_after_linking_cycles(Main *bmain) diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc index 515adab5b57..5686bcac5cb 100644 --- a/source/blender/depsgraph/intern/builder/deg_builder_relations.cc +++ b/source/blender/depsgraph/intern/builder/deg_builder_relations.cc @@ -2069,9 +2069,9 @@ void DepsgraphRelationBuilder::build_camera(Camera *camera) } build_animdata(&camera->id); build_parameters(&camera->id); - if (camera->dof_ob != NULL) { + if (camera->dof.focus_object != NULL) { ComponentKey camera_parameters_key(&camera->id, NodeType::PARAMETERS); - ComponentKey dof_ob_key(&camera->dof_ob->id, NodeType::TRANSFORM); + ComponentKey dof_ob_key(&camera->dof.focus_object->id, NodeType::TRANSFORM); add_relation(dof_ob_key, camera_parameters_key, "Camera DOF"); } } diff --git a/source/blender/draw/engines/eevee/eevee_depth_of_field.c b/source/blender/draw/engines/eevee/eevee_depth_of_field.c index 3d058f7e46e..25d256e86b3 100644 --- a/source/blender/draw/engines/eevee/eevee_depth_of_field.c +++ b/source/blender/draw/engines/eevee/eevee_depth_of_field.c @@ -79,7 +79,9 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); - if (scene_eval->eevee.flag & SCE_EEVEE_DOF_ENABLED) { + Camera *cam = (camera != NULL) ? camera->data : NULL; + + if (cam && (cam->dof.flag & CAM_DOF_ENABLED)) { RegionView3D *rv3d = draw_ctx->rv3d; const bool use_alpha = !DRW_state_draw_background(); @@ -87,94 +89,89 @@ int EEVEE_depth_of_field_init(EEVEE_ViewLayerData *UNUSED(sldata), eevee_create_shader_depth_of_field(use_alpha); } - if (camera) { - const float *viewport_size = DRW_viewport_size_get(); - Camera *cam = (Camera *)camera->data; - - /* Retrieve Near and Far distance */ - effects->dof_near_far[0] = -cam->clip_start; - effects->dof_near_far[1] = -cam->clip_end; - - int buffer_size[2] = {(int)viewport_size[0] / 2, (int)viewport_size[1] / 2}; - - eGPUTextureFormat down_format = DRW_state_draw_background() ? GPU_R11F_G11F_B10F : - GPU_RGBA16F; - - effects->dof_down_near = DRW_texture_pool_query_2d( - buffer_size[0], buffer_size[1], down_format, &draw_engine_eevee_type); - effects->dof_down_far = DRW_texture_pool_query_2d( - buffer_size[0], buffer_size[1], down_format, &draw_engine_eevee_type); - effects->dof_coc = DRW_texture_pool_query_2d( - buffer_size[0], buffer_size[1], GPU_RG16F, &draw_engine_eevee_type); - - GPU_framebuffer_ensure_config(&fbl->dof_down_fb, - {GPU_ATTACHMENT_NONE, - GPU_ATTACHMENT_TEXTURE(effects->dof_down_near), - GPU_ATTACHMENT_TEXTURE(effects->dof_down_far), - GPU_ATTACHMENT_TEXTURE(effects->dof_coc)}); - - /* Go full 32bits for rendering and reduce the color artifacts. */ - eGPUTextureFormat fb_format = DRW_state_is_image_render() ? GPU_RGBA32F : GPU_RGBA16F; - - effects->dof_blur = DRW_texture_pool_query_2d( - buffer_size[0] * 2, buffer_size[1], fb_format, &draw_engine_eevee_type); - - GPU_framebuffer_ensure_config(&fbl->dof_scatter_fb, - { - GPU_ATTACHMENT_NONE, - GPU_ATTACHMENT_TEXTURE(effects->dof_blur), - }); - - if (!DRW_state_draw_background()) { - effects->dof_blur_alpha = DRW_texture_pool_query_2d( - buffer_size[0] * 2, buffer_size[1], GPU_R32F, &draw_engine_eevee_type); - GPU_framebuffer_texture_attach(fbl->dof_scatter_fb, effects->dof_blur_alpha, 1, 0); - } - - /* Parameters */ - /* TODO UI Options */ - float fstop = cam->gpu_dof.fstop; - float blades = cam->gpu_dof.num_blades; - float rotation = cam->gpu_dof.rotation; - float ratio = 1.0f / cam->gpu_dof.ratio; - float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); - float focus_dist = BKE_camera_object_dof_distance(camera); - float focal_len = cam->lens; - - /* this is factor that converts to the scene scale. focal length and sensor are expressed in - * mm unit.scale_length is how many meters per blender unit we have. We want to convert to - * blender units though because the shader reads coordinates in world space, which is in - * blender units. - * Note however that focus_distance is already in blender units and shall not be scaled here - * (see T48157). */ - float scale = (scene_eval->unit.system) ? scene_eval->unit.scale_length : 1.0f; - float scale_camera = 0.001f / scale; - /* we want radius here for the aperture number */ - float aperture = 0.5f * scale_camera * focal_len / fstop; - float focal_len_scaled = scale_camera * focal_len; - float sensor_scaled = scale_camera * sensor; - - if (rv3d != NULL) { - sensor_scaled *= rv3d->viewcamtexcofac[0]; - } - - effects->dof_params[1] = aperture * - fabsf(focal_len_scaled / (focus_dist - focal_len_scaled)); - effects->dof_params[1] *= viewport_size[0] / sensor_scaled; - effects->dof_params[0] = -focus_dist * effects->dof_params[1]; - - effects->dof_bokeh[0] = rotation; - effects->dof_bokeh[1] = ratio; - effects->dof_bokeh[2] = scene_eval->eevee.bokeh_max_size; - - /* Precompute values to save instructions in fragment shader. */ - effects->dof_bokeh_sides[0] = blades; - effects->dof_bokeh_sides[1] = blades > 0.0f ? 2.0f * M_PI / blades : 0.0f; - effects->dof_bokeh_sides[2] = blades / (2.0f * M_PI); - effects->dof_bokeh_sides[3] = blades > 0.0f ? cosf(M_PI / blades) : 0.0f; - - return EFFECT_DOF | EFFECT_POST_BUFFER; + const float *viewport_size = DRW_viewport_size_get(); + + /* Retrieve Near and Far distance */ + effects->dof_near_far[0] = -cam->clip_start; + effects->dof_near_far[1] = -cam->clip_end; + + int buffer_size[2] = {(int)viewport_size[0] / 2, (int)viewport_size[1] / 2}; + + eGPUTextureFormat down_format = DRW_state_draw_background() ? GPU_R11F_G11F_B10F : GPU_RGBA16F; + + effects->dof_down_near = DRW_texture_pool_query_2d( + buffer_size[0], buffer_size[1], down_format, &draw_engine_eevee_type); + effects->dof_down_far = DRW_texture_pool_query_2d( + buffer_size[0], buffer_size[1], down_format, &draw_engine_eevee_type); + effects->dof_coc = DRW_texture_pool_query_2d( + buffer_size[0], buffer_size[1], GPU_RG16F, &draw_engine_eevee_type); + + GPU_framebuffer_ensure_config(&fbl->dof_down_fb, + {GPU_ATTACHMENT_NONE, + GPU_ATTACHMENT_TEXTURE(effects->dof_down_near), + GPU_ATTACHMENT_TEXTURE(effects->dof_down_far), + GPU_ATTACHMENT_TEXTURE(effects->dof_coc)}); + + /* Go full 32bits for rendering and reduce the color artifacts. */ + eGPUTextureFormat fb_format = DRW_state_is_image_render() ? GPU_RGBA32F : GPU_RGBA16F; + + effects->dof_blur = DRW_texture_pool_query_2d( + buffer_size[0] * 2, buffer_size[1], fb_format, &draw_engine_eevee_type); + + GPU_framebuffer_ensure_config(&fbl->dof_scatter_fb, + { + GPU_ATTACHMENT_NONE, + GPU_ATTACHMENT_TEXTURE(effects->dof_blur), + }); + + if (!DRW_state_draw_background()) { + effects->dof_blur_alpha = DRW_texture_pool_query_2d( + buffer_size[0] * 2, buffer_size[1], GPU_R32F, &draw_engine_eevee_type); + GPU_framebuffer_texture_attach(fbl->dof_scatter_fb, effects->dof_blur_alpha, 1, 0); + } + + /* Parameters */ + /* TODO UI Options */ + float fstop = cam->dof.aperture_fstop; + float blades = cam->dof.aperture_blades; + float rotation = cam->dof.aperture_rotation; + float ratio = 1.0f / cam->dof.aperture_ratio; + float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); + float focus_dist = BKE_camera_object_dof_distance(camera); + float focal_len = cam->lens; + + /* this is factor that converts to the scene scale. focal length and sensor are expressed in + * mm unit.scale_length is how many meters per blender unit we have. We want to convert to + * blender units though because the shader reads coordinates in world space, which is in + * blender units. + * Note however that focus_distance is already in blender units and shall not be scaled here + * (see T48157). */ + float scale = (scene_eval->unit.system) ? scene_eval->unit.scale_length : 1.0f; + float scale_camera = 0.001f / scale; + /* we want radius here for the aperture number */ + float aperture = 0.5f * scale_camera * focal_len / fstop; + float focal_len_scaled = scale_camera * focal_len; + float sensor_scaled = scale_camera * sensor; + + if (rv3d != NULL) { + sensor_scaled *= rv3d->viewcamtexcofac[0]; } + + effects->dof_params[1] = aperture * fabsf(focal_len_scaled / (focus_dist - focal_len_scaled)); + effects->dof_params[1] *= viewport_size[0] / sensor_scaled; + effects->dof_params[0] = -focus_dist * effects->dof_params[1]; + + effects->dof_bokeh[0] = rotation; + effects->dof_bokeh[1] = ratio; + effects->dof_bokeh[2] = scene_eval->eevee.bokeh_max_size; + + /* Precompute values to save instructions in fragment shader. */ + effects->dof_bokeh_sides[0] = blades; + effects->dof_bokeh_sides[1] = blades > 0.0f ? 2.0f * M_PI / blades : 0.0f; + effects->dof_bokeh_sides[2] = blades / (2.0f * M_PI); + effects->dof_bokeh_sides[3] = blades > 0.0f ? cosf(M_PI / blades) : 0.0f; + + return EFFECT_DOF | EFFECT_POST_BUFFER; } /* Cleanup to release memory */ diff --git a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c index ccb79ea2b93..d46e850ba82 100644 --- a/source/blender/draw/engines/gpencil/gpencil_shader_fx.c +++ b/source/blender/draw/engines/gpencil/gpencil_shader_fx.c @@ -115,7 +115,7 @@ static void GPENCIL_dof_nearfar(Object *camera, float coc, float nearfar[2]) Scene *scene = draw_ctx->scene; Camera *cam = (Camera *)camera->data; - float fstop = cam->gpu_dof.fstop; + float fstop = cam->dof.aperture_fstop; float focus_dist = BKE_camera_object_dof_distance(camera); float focal_len = cam->lens; diff --git a/source/blender/draw/engines/workbench/workbench_effect_dof.c b/source/blender/draw/engines/workbench/workbench_effect_dof.c index ee8c8a0343f..6886b73650c 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_dof.c +++ b/source/blender/draw/engines/workbench/workbench_effect_dof.c @@ -136,7 +136,9 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera) WORKBENCH_PrivateData *wpd = stl->g_data; WORKBENCH_FramebufferList *fbl = vedata->fbl; - if ((wpd->shading.flag & V3D_SHADING_DEPTH_OF_FIELD) == 0 || (camera == NULL)) { + Camera *cam = camera != NULL ? camera->data : NULL; + if ((wpd->shading.flag & V3D_SHADING_DEPTH_OF_FIELD) == 0 || (cam == NULL) || + ((cam->dof.flag & CAM_DOF_ENABLED) == 0)) { wpd->dof_enabled = false; return; } @@ -231,11 +233,10 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera) const DRWContextState *draw_ctx = DRW_context_state_get(); const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); RegionView3D *rv3d = draw_ctx->rv3d; - Camera *cam = (Camera *)camera->data; /* Parameters */ /* TODO UI Options */ - float fstop = cam->gpu_dof.fstop; + float fstop = cam->dof.aperture_fstop; float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); float focus_dist = BKE_camera_object_dof_distance(camera); float focal_len = cam->lens; @@ -265,9 +266,9 @@ void workbench_dof_engine_init(WORKBENCH_Data *vedata, Object *camera) wpd->dof_near_far[0] = -cam->clip_start; wpd->dof_near_far[1] = -cam->clip_end; - float blades = cam->gpu_dof.num_blades; - float rotation = cam->gpu_dof.rotation; - float ratio = 1.0f / cam->gpu_dof.ratio; + float blades = cam->dof.aperture_blades; + float rotation = cam->dof.aperture_rotation; + float ratio = 1.0f / cam->dof.aperture_ratio; if (wpd->dof_ubo == NULL || blades != wpd->dof_blades || rotation != wpd->dof_rotation || ratio != wpd->dof_ratio) { diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h index 8974f3d6374..cd4cefe8891 100644 --- a/source/blender/editors/include/ED_view3d.h +++ b/source/blender/editors/include/ED_view3d.h @@ -570,7 +570,6 @@ void ED_view3d_draw_offscreen(struct Depsgraph *depsgraph, bool do_sky, bool is_persp, const char *viewname, - struct GPUFXSettings *fx_settings, const bool do_color_managment, struct GPUOffScreen *ofs, struct GPUViewport *viewport); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 8c5f1c16438..afc3b80fe3e 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -1503,7 +1503,6 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph, bool do_sky, bool UNUSED(is_persp), const char *viewname, - GPUFXSettings *UNUSED(fx_settings), const bool do_color_management, GPUOffScreen *ofs, GPUViewport *viewport) @@ -1593,7 +1592,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, const bool use_full_sample = (draw_flags & V3D_OFSDRAW_USE_FULL_SAMPLE); /* view state */ - GPUFXSettings fx_settings = v3d->fx_settings; bool is_ortho = false; float winmat[4][4]; @@ -1640,8 +1638,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, BKE_camera_params_compute_viewplane(¶ms, sizex, sizey, scene->r.xasp, scene->r.yasp); BKE_camera_params_compute_matrix(¶ms); - BKE_camera_to_gpu_dof(camera, &fx_settings); - is_ortho = params.is_ortho; copy_m4_m4(winmat, params.winmat); } @@ -1686,7 +1682,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, draw_sky, !is_ortho, viewname, - &fx_settings, do_color_management, ofs, NULL); @@ -1724,7 +1719,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, draw_sky, !is_ortho, viewname, - &fx_settings, false, ofs, viewport); @@ -1750,7 +1744,6 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Depsgraph *depsgraph, draw_sky, !is_ortho, viewname, - &fx_settings, false, ofs, viewport); diff --git a/source/blender/editors/space_view3d/view3d_gizmo_camera.c b/source/blender/editors/space_view3d/view3d_gizmo_camera.c index 0b8c3b8cd28..5fe62a74d4b 100644 --- a/source/blender/editors/space_view3d/view3d_gizmo_camera.c +++ b/source/blender/editors/space_view3d/view3d_gizmo_camera.c @@ -154,7 +154,7 @@ static void WIDGETGROUP_camera_refresh(const bContext *C, wmGizmoGroup *gzgroup) /* need to set property here for undo. TODO would prefer to do this in _init */ WM_gizmo_target_property_def_rna( - cagzgroup->dop_dist, "offset", &camera_ptr, "dof_distance", -1); + cagzgroup->dop_dist, "offset", &camera_ptr, "dof.focus_distance", -1); } else { WM_gizmo_set_flag(cagzgroup->dop_dist, WM_GIZMO_HIDDEN, true); @@ -262,7 +262,7 @@ static void WIDGETGROUP_camera_message_subscribe(const bContext *C, }; { - extern PropertyRNA rna_Camera_dof_distance; + extern PropertyRNA rna_CameraDOFSettings_focus_distance; extern PropertyRNA rna_Camera_display_size; extern PropertyRNA rna_Camera_ortho_scale; extern PropertyRNA rna_Camera_sensor_fit; @@ -273,7 +273,7 @@ static void WIDGETGROUP_camera_message_subscribe(const bContext *C, extern PropertyRNA rna_Camera_type; extern PropertyRNA rna_Camera_lens; const PropertyRNA *props[] = { - &rna_Camera_dof_distance, + &rna_CameraDOFSettings_focus_distance, &rna_Camera_display_size, &rna_Camera_ortho_scale, &rna_Camera_sensor_fit, diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h index 8c5d911b7fa..b78b2f64648 100644 --- a/source/blender/makesdna/DNA_camera_types.h +++ b/source/blender/makesdna/DNA_camera_types.h @@ -67,6 +67,19 @@ typedef struct CameraBGImage { short source; } CameraBGImage; +/** Properties for dof effect. */ +typedef struct CameraDOFSettings { + /** Focal distance for depth of field. */ + struct Object *focus_object; + float focus_distance; + float aperture_fstop; + float aperture_rotation; + float aperture_ratio; + int aperture_blades; + short flag; + char _pad[2]; +} CameraDOFSettings; + typedef struct Camera_Runtime { /* For draw manager. */ float drw_corners[2][4][2]; @@ -91,13 +104,14 @@ typedef struct Camera { float lens, ortho_scale, drawsize; float sensor_x, sensor_y; float shiftx, shifty; - float dof_distance; + float dof_distance DNA_DEPRECATED; /** Old animation system, deprecated for 2.5. */ struct Ipo *ipo DNA_DEPRECATED; - struct Object *dof_ob; - struct GPUDOFSettings gpu_dof; + struct Object *dof_ob DNA_DEPRECATED; + struct GPUDOFSettings gpu_dof DNA_DEPRECATED; + struct CameraDOFSettings dof; /* CameraBGImage reference images */ struct ListBase bg_images; @@ -204,6 +218,11 @@ enum { CAM_BGIMG_SOURCE_MOVIE = 1, }; +/* CameraDOFSettings->flag */ +enum { + CAM_DOF_ENABLED = (1 << 0), +}; + #ifdef __cplusplus } #endif diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h index c64a593c9e2..0f6d028ea35 100644 --- a/source/blender/makesdna/DNA_scene_types.h +++ b/source/blender/makesdna/DNA_scene_types.h @@ -2376,7 +2376,7 @@ enum { SCE_EEVEE_GTAO_ENABLED = (1 << 4), SCE_EEVEE_GTAO_BENT_NORMALS = (1 << 5), SCE_EEVEE_GTAO_BOUNCE = (1 << 6), - SCE_EEVEE_DOF_ENABLED = (1 << 7), + // SCE_EEVEE_DOF_ENABLED = (1 << 7), /* Moved to camera->dof.flag */ SCE_EEVEE_BLOOM_ENABLED = (1 << 8), SCE_EEVEE_MOTION_BLUR_ENABLED = (1 << 9), SCE_EEVEE_SHADOW_HIGH_BITDEPTH = (1 << 10), diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c index 0ea1ca9c018..c09ada4a41d 100644 --- a/source/blender/makesdna/intern/makesdna.c +++ b/source/blender/makesdna/intern/makesdna.c @@ -41,6 +41,8 @@ * numbers give more output. */ +#define DNA_DEPRECATED_ALLOW + #include #include #include diff --git a/source/blender/makesrna/RNA_access.h b/source/blender/makesrna/RNA_access.h index 5aee34df6f7..e3be9fd64be 100644 --- a/source/blender/makesrna/RNA_access.h +++ b/source/blender/makesrna/RNA_access.h @@ -97,6 +97,7 @@ extern StructRNA RNA_BuildGpencilModifier; extern StructRNA RNA_BuildModifier; extern StructRNA RNA_CacheFile; extern StructRNA RNA_Camera; +extern StructRNA RNA_CameraDOFSettings; extern StructRNA RNA_CastModifier; extern StructRNA RNA_ChildOfConstraint; extern StructRNA RNA_ChildParticle; diff --git a/source/blender/makesrna/intern/rna_camera.c b/source/blender/makesrna/intern/rna_camera.c index 1f356624f3f..6bab07d2940 100644 --- a/source/blender/makesrna/intern/rna_camera.c +++ b/source/blender/makesrna/intern/rna_camera.c @@ -131,6 +131,38 @@ static void rna_Camera_dof_update(Main *bmain, Scene *scene, PointerRNA *UNUSED( WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); } +char *rna_CameraDOFSettings_path(PointerRNA *ptr) +{ + /* if there is ID-data, resolve the path using the index instead of by name, + * since the name used is the name of the texture assigned, but the texture + * may be used multiple times in the same stack + */ + if (ptr->id.data) { + if (GS(((ID *)ptr->id.data)->name) == ID_CA) { + return BLI_strdup("dof"); + } + } + + return BLI_strdup(""); +} + +static void rna_CameraDOFSettings_aperture_blades_set(PointerRNA *ptr, const int value) +{ + CameraDOFSettings *dofsettings = (CameraDOFSettings *)ptr->data; + + if (value == 1 || value == 2) { + if (dofsettings->aperture_blades == 0) { + dofsettings->aperture_blades = 3; + } + else { + dofsettings->aperture_blades = 0; + } + } + else { + dofsettings->aperture_blades = value; + } +} + #else static void rna_def_camera_background_image(BlenderRNA *brna) @@ -376,6 +408,68 @@ static void rna_def_camera_stereo_data(BlenderRNA *brna) RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); } +static void rna_def_camera_dof_settings_data(BlenderRNA *brna) +{ + StructRNA *srna; + PropertyRNA *prop; + + srna = RNA_def_struct(brna, "CameraDOFSettings", NULL); + RNA_def_struct_sdna(srna, "CameraDOFSettings"); + RNA_def_struct_path_func(srna, "rna_CameraDOFSettings_path"); + RNA_def_struct_ui_text(srna, "Depth of Field", "Depth of Field settings"); + + prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_boolean_sdna(prop, NULL, "flag", CAM_DOF_ENABLED); + RNA_def_property_ui_text(prop, "Depth of Field", "Use Depth of Field"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update"); + + prop = RNA_def_property(srna, "focus_object", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "Object"); + RNA_def_property_pointer_sdna(prop, NULL, "focus_object"); + RNA_def_property_flag(prop, PROP_EDITABLE); + RNA_def_property_ui_text( + prop, "Focus Object", "Use this object to define the depth of field focal point"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update"); + + prop = RNA_def_property(srna, "focus_distance", PROP_FLOAT, PROP_DISTANCE); + RNA_def_property_float_default(prop, 10.0f); + // RNA_def_property_pointer_sdna(prop, NULL, "focus_distance"); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.0f, 5000.0f, 1, 2); + RNA_def_property_ui_text( + prop, "Focus Distance", "Distance to the focus point for depth of field"); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update"); + + prop = RNA_def_property(srna, "aperture_fstop", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text( + prop, + "F-Stop", + "F-Stop ratio (lower numbers give more defocus, higher numbers give a sharper image)"); + RNA_def_property_float_default(prop, 5.6f); + RNA_def_property_range(prop, 0.0f, FLT_MAX); + RNA_def_property_ui_range(prop, 0.1f, 128.0f, 10, 1); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update"); + + prop = RNA_def_property(srna, "aperture_blades", PROP_INT, PROP_NONE); + RNA_def_property_ui_text( + prop, "Blades", "Number of blades in aperture for polygonal bokeh (at least 3)"); + RNA_def_property_range(prop, 0, 16); + RNA_def_property_int_funcs(prop, NULL, "rna_CameraDOFSettings_aperture_blades_set", NULL); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update"); + + prop = RNA_def_property(srna, "aperture_rotation", PROP_FLOAT, PROP_ANGLE); + RNA_def_property_ui_text(prop, "Rotation", "Rotation of blades in aperture"); + RNA_def_property_range(prop, -M_PI, M_PI); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update"); + + prop = RNA_def_property(srna, "aperture_ratio", PROP_FLOAT, PROP_NONE); + RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh"); + RNA_def_property_float_default(prop, 1.0f); + RNA_def_property_range(prop, 0.01f, FLT_MAX); + RNA_def_property_ui_range(prop, 1.0f, 2.0f, 0.1, 3); + RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update"); +} + void RNA_def_camera(BlenderRNA *brna) { StructRNA *srna; @@ -525,12 +619,6 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Shift Y", "Camera vertical shift"); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_update"); - prop = RNA_def_property(srna, "dof_distance", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0f, 5000.0f, 1, 2); - RNA_def_property_ui_text(prop, "DOF Distance", "Distance to the focus point for depth of field"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dof_update"); - /* Stereo Settings */ prop = RNA_def_property(srna, "stereo", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); @@ -645,17 +733,9 @@ void RNA_def_camera(BlenderRNA *brna) RNA_def_property_update(prop, NC_CAMERA | ND_DRAW_RENDER_VIEWPORT, NULL); /* pointers */ - prop = RNA_def_property(srna, "dof_object", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "Object"); - RNA_def_property_pointer_sdna(prop, NULL, "dof_ob"); - RNA_def_property_flag(prop, PROP_EDITABLE); - RNA_def_property_ui_text( - prop, "DOF Object", "Use this object to define the depth of field focal point"); - RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Camera_dependency_update"); - - prop = RNA_def_property(srna, "gpu_dof", PROP_POINTER, PROP_NONE); - RNA_def_property_struct_type(prop, "GPUDOFSettings"); - RNA_def_property_ui_text(prop, "GPU Depth Of Field", ""); + prop = RNA_def_property(srna, "dof", PROP_POINTER, PROP_NONE); + RNA_def_property_struct_type(prop, "CameraDOFSettings"); + RNA_def_property_ui_text(prop, "Depth Of Field", ""); RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, NULL); prop = RNA_def_property(srna, "background_images", PROP_COLLECTION, PROP_NONE); @@ -674,6 +754,7 @@ void RNA_def_camera(BlenderRNA *brna) /* *** Animated *** */ rna_def_camera_stereo_data(brna); + rna_def_camera_dof_settings_data(brna); /* Camera API */ RNA_api_camera(srna); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 4584cadb51d..a4d263b7927 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2155,45 +2155,6 @@ void rna_FreestyleSettings_module_remove(ID *id, WM_main_add_notifier(NC_SCENE | ND_RENDER_OPTIONS, NULL); } -char *rna_GPUDOF_path(PointerRNA *ptr) -{ - /* if there is ID-data, resolve the path using the index instead of by name, - * since the name used is the name of the texture assigned, but the texture - * may be used multiple times in the same stack - */ - if (ptr->id.data) { - if (GS(((ID *)ptr->id.data)->name) == ID_CA) { - return BLI_strdup("gpu_dof"); - } - } - - return BLI_strdup(""); -} - -static void rna_GPUDOFSettings_blades_set(PointerRNA *ptr, const int value) -{ - GPUDOFSettings *dofsettings = (GPUDOFSettings *)ptr->data; - - if (value == 1 || value == 2) { - if (dofsettings->num_blades == 0) { - dofsettings->num_blades = 3; - } - else { - dofsettings->num_blades = 0; - } - } - else { - dofsettings->num_blades = value; - } -} - -static void rna_GPUDOFSettings_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr)) -{ - /* TODO(sergey): Can be more selective here. */ - BKE_sequencer_cache_cleanup_all(bmain); - WM_main_add_notifier(NC_SCENE | ND_SEQUENCER, scene); -} - static void rna_Stereo3dFormat_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *ptr) { ID *id = ptr->id.data; @@ -4734,60 +4695,6 @@ static void rna_def_bake_data(BlenderRNA *brna) RNA_def_property_clear_flag(prop, PROP_EDITABLE); } -static void rna_def_gpu_dof_fx(BlenderRNA *brna) -{ - StructRNA *srna; - PropertyRNA *prop; - - srna = RNA_def_struct(brna, "GPUDOFSettings", NULL); - RNA_def_struct_ui_text(srna, "GPU DOF", "Settings for GPU based depth of field"); - RNA_def_struct_path_func(srna, "rna_GPUDOF_path"); - - prop = RNA_def_property(srna, "focus_distance", PROP_FLOAT, PROP_DISTANCE); - RNA_def_property_ui_text(prop, "Focus distance", "Viewport depth of field focus distance"); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.0f, 5000.0f, 1, 2); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUDOFSettings_update"); - - prop = RNA_def_property(srna, "focal_length", PROP_FLOAT, PROP_DISTANCE_CAMERA); - RNA_def_property_ui_text(prop, "Focal Length", "Focal length for dof effect"); - RNA_def_property_range(prop, 1.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 1, 2); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUDOFSettings_update"); - - prop = RNA_def_property(srna, "sensor", PROP_FLOAT, PROP_DISTANCE_CAMERA); - RNA_def_property_ui_text(prop, "Sensor", "Size of sensor"); - RNA_def_property_range(prop, 1.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 1.0f, 5000.0f, 1, 2); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUDOFSettings_update"); - - prop = RNA_def_property(srna, "fstop", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_text(prop, "F-stop", "F-stop for dof effect"); - RNA_def_property_float_default(prop, 128.0f); - RNA_def_property_range(prop, 0.0f, FLT_MAX); - RNA_def_property_ui_range(prop, 0.1f, 128.0f, 10, 1); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUDOFSettings_update"); - - prop = RNA_def_property(srna, "blades", PROP_INT, PROP_NONE); - RNA_def_property_int_sdna(prop, NULL, "num_blades"); - RNA_def_property_ui_text(prop, "Blades", "Blades for dof effect"); - RNA_def_property_range(prop, 0, 16); - RNA_def_property_int_funcs(prop, NULL, "rna_GPUDOFSettings_blades_set", NULL); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_GPUDOFSettings_update"); - - prop = RNA_def_property(srna, "rotation", PROP_FLOAT, PROP_ANGLE); - RNA_def_property_ui_text(prop, "Rotation", "Rotation of blades in aperture"); - RNA_def_property_range(prop, -M_PI, M_PI); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - - prop = RNA_def_property(srna, "ratio", PROP_FLOAT, PROP_NONE); - RNA_def_property_ui_text(prop, "Ratio", "Distortion to simulate anamorphic lens bokeh"); - RNA_def_property_float_default(prop, 1.0f); - RNA_def_property_range(prop, 0.01f, FLT_MAX); - RNA_def_property_ui_range(prop, 1.0f, 2.0f, 0.1, 3); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); -} - static void rna_def_gpu_ssao_fx(BlenderRNA *brna) { StructRNA *srna; @@ -4832,23 +4739,10 @@ static void rna_def_gpu_fx(BlenderRNA *brna) PropertyRNA *prop; rna_def_gpu_ssao_fx(brna); - rna_def_gpu_dof_fx(brna); srna = RNA_def_struct(brna, "GPUFXSettings", NULL); RNA_def_struct_ui_text(srna, "GPU FX Settings", "Settings for GPU based compositing"); - prop = RNA_def_property(srna, "dof", PROP_POINTER, PROP_NONE); - RNA_def_property_flag(prop, PROP_NEVER_NULL); - RNA_def_property_struct_type(prop, "GPUDOFSettings"); - RNA_def_property_ui_text(prop, "Depth Of Field settings", ""); - - prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "fx_flag", GPU_FX_FLAG_DOF); - RNA_def_property_ui_text(prop, - "Depth Of Field", - "Use depth of field on viewport using the values from active camera"); - RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL); - prop = RNA_def_property(srna, "ssao", PROP_POINTER, PROP_NONE); RNA_def_property_flag(prop, PROP_NEVER_NULL); RNA_def_property_struct_type(prop, "GPUSSAOSettings"); @@ -7004,14 +6898,6 @@ static void rna_def_scene_eevee(BlenderRNA *brna) RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); /* Depth of Field */ - prop = RNA_def_property(srna, "use_dof", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_sdna(prop, NULL, "flag", SCE_EEVEE_DOF_ENABLED); - RNA_def_property_boolean_default(prop, 0); - RNA_def_property_ui_text( - prop, "Depth of Field", "Enable depth of field using the values from the active camera"); - RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC); - RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, NULL); - prop = RNA_def_property(srna, "bokeh_max_size", PROP_FLOAT, PROP_PIXEL); RNA_def_property_float_default(prop, 100.0f); RNA_def_property_ui_text( diff --git a/source/blender/python/gpu/gpu_py_offscreen.c b/source/blender/python/gpu/gpu_py_offscreen.c index 5ea747b5cdc..561aff41000 100644 --- a/source/blender/python/gpu/gpu_py_offscreen.c +++ b/source/blender/python/gpu/gpu_py_offscreen.c @@ -256,7 +256,6 @@ static PyObject *bpygpu_offscreen_draw_view3d(BPyGPUOffScreen *self, false, true, "", - NULL, true, self->ofs, NULL); -- cgit v1.2.3