diff options
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_camera.h | 3 | ||||
-rw-r--r-- | source/blender/blenkernel/BKE_screen.h | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/camera.c | 21 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/screen.c | 25 |
4 files changed, 50 insertions, 1 deletions
diff --git a/source/blender/blenkernel/BKE_camera.h b/source/blender/blenkernel/BKE_camera.h index 26d4986d93e..77296920ee2 100644 --- a/source/blender/blenkernel/BKE_camera.h +++ b/source/blender/blenkernel/BKE_camera.h @@ -46,6 +46,7 @@ struct RenderData; struct Scene; struct rctf; struct View3D; +struct GPUFXSettings; /* Camera Datablock */ @@ -122,6 +123,8 @@ bool BKE_camera_view_frame_fit_to_scene(struct Scene *scene, struct View3D *v3d, bool BKE_camera_view_frame_fit_to_coords(struct Scene *scene, float (*cos)[3], int num_cos, struct Object *camera_ob, float r_co[3], float *r_scale); +void BKE_camera_to_gpu_dof(struct Object *camera, struct GPUFXSettings *r_fx_settings); + #ifdef __cplusplus } #endif diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 3eb6ba7b6fa..29590c52b23 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -52,6 +52,7 @@ struct wmKeyConfig; struct wmNotifier; struct wmWindow; struct wmWindowManager; +struct GPUFXSettings; #include "BLI_compiler_attrs.h" @@ -294,6 +295,7 @@ void BKE_screen_view3d_scene_sync(struct bScreen *sc); void BKE_screen_view3d_main_sync(ListBase *screen_lb, struct Scene *scene); void BKE_screen_view3d_twmode_remove(struct View3D *v3d, const int i); void BKE_screen_view3d_main_twmode_remove(ListBase *screen_lb, struct Scene *scene, const int i); +void BKE_screen_gpu_fx_validate(struct GPUFXSettings *fx_settings); /* zoom factor conversion */ float BKE_screen_view3d_zoom_to_fac(float camzoom); diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index e424823d8dc..e1d771dad65 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -49,6 +49,8 @@ #include "BKE_main.h" #include "BKE_screen.h" +#include "GPU_compositing.h" + /****************************** Camera Datablock *****************************/ void *BKE_camera_add(Main *bmain, const char *name) @@ -66,7 +68,9 @@ void *BKE_camera_add(Main *bmain, const char *name) cam->ortho_scale = 6.0; cam->flag |= CAM_SHOWPASSEPARTOUT; cam->passepartalpha = 0.5f; - + + GPU_fx_compositor_init_dof_settings(&cam->gpu_dof); + return cam; } @@ -686,3 +690,18 @@ bool BKE_camera_view_frame_fit_to_coords( return camera_frame_fit_calc_from_data(¶ms, &data_cb, r_co, r_scale); } +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); + if (cam->dof_ob) { + r_fx_settings->dof->focus_distance = len_v3v3(cam->dof_ob->obmat[3], camera->obmat[3]); + } + else { + r_fx_settings->dof->focus_distance = cam->YF_dofdist; + } + } +} diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c index c9dba38b713..a6ac4551f4a 100644 --- a/source/blender/blenkernel/intern/screen.c +++ b/source/blender/blenkernel/intern/screen.c @@ -39,6 +39,8 @@ #include "MEM_guardedalloc.h" +#include "GPU_compositing.h" + #include "DNA_scene_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -598,3 +600,26 @@ float BKE_screen_view3d_zoom_from_fac(float zoomfac) { return ((sqrtf(4.0f * zoomfac) - (float)M_SQRT2) * 50.0f); } + +void BKE_screen_gpu_fx_validate(GPUFXSettings *fx_settings) +{ + /* currently we use DOF from the camera _only_, + * so we never allocate this, only copy from the Camera */ +#if 0 + if ((fx_settings->dof == NULL) && + (fx_settings->fx_flag & GPU_FX_FLAG_DOF)) + { + GPUDOFSettings *fx_dof; + fx_dof = fx_settings->dof = MEM_callocN(sizeof(GPUDOFSettings), __func__); + } +#endif + + if ((fx_settings->ssao == NULL) && + (fx_settings->fx_flag & GPU_FX_FLAG_SSAO)) + { + GPUSSAOSettings *fx_ssao; + fx_ssao = fx_settings->ssao = MEM_callocN(sizeof(GPUSSAOSettings), __func__); + + GPU_fx_compositor_init_ssao_settings(fx_ssao); + } +} |