Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/workbench/workbench_effect_dof.c
| Show First 20 Lines • Show All 225 Lines • ▼ Show 20 Lines | #endif | ||||
| GPU_framebuffer_ensure_config(&fbl->dof_blur2_fb, | GPU_framebuffer_ensure_config(&fbl->dof_blur2_fb, | ||||
| { | { | ||||
| GPU_ATTACHMENT_NONE, | GPU_ATTACHMENT_NONE, | ||||
| GPU_ATTACHMENT_TEXTURE(txl->dof_source_tx), | GPU_ATTACHMENT_TEXTURE(txl->dof_source_tx), | ||||
| }); | }); | ||||
| { | { | ||||
| const DRWContextState *draw_ctx = DRW_context_state_get(); | const DRWContextState *draw_ctx = DRW_context_state_get(); | ||||
| const Scene *scene_eval = DEG_get_evaluated_scene(draw_ctx->depsgraph); | |||||
| RegionView3D *rv3d = draw_ctx->rv3d; | RegionView3D *rv3d = draw_ctx->rv3d; | ||||
| /* Parameters */ | /* Parameters */ | ||||
| /* TODO UI Options */ | /* TODO UI Options */ | ||||
| float fstop = cam->dof.aperture_fstop; | float fstop = cam->dof.aperture_fstop; | ||||
| float sensor = BKE_camera_sensor_size(cam->sensor_fit, cam->sensor_x, cam->sensor_y); | 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 focus_dist = BKE_camera_object_dof_distance(camera); | ||||
| float focal_len = cam->lens; | float focal_len = cam->lens; | ||||
| /* TODO(fclem) deduplicate with eevee */ | /* TODO(fclem) deduplicate with eevee */ | ||||
| const float scale_camera = 0.001f; | |||||
| /* 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 */ | /* we want radius here for the aperture number */ | ||||
| float aperture = 0.5f * scale_camera * focal_len / fstop; | float aperture = 0.5f * scale_camera * focal_len / fstop; | ||||
| float focal_len_scaled = scale_camera * focal_len; | float focal_len_scaled = scale_camera * focal_len; | ||||
| float sensor_scaled = scale_camera * sensor; | float sensor_scaled = scale_camera * sensor; | ||||
| if (rv3d != NULL) { | if (rv3d != NULL) { | ||||
| sensor_scaled *= rv3d->viewcamtexcofac[0]; | sensor_scaled *= rv3d->viewcamtexcofac[0]; | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 183 Lines • Show Last 20 Lines | |||||