Changeset View
Changeset View
Standalone View
Standalone View
source/blender/draw/engines/eevee/eevee_depth_of_field.c
| Show All 39 Lines | |||||
| #include "BKE_global.h" /* for G.debug_value */ | #include "BKE_global.h" /* for G.debug_value */ | ||||
| #include "BKE_camera.h" | #include "BKE_camera.h" | ||||
| #include "BKE_mesh.h" | #include "BKE_mesh.h" | ||||
| #include "BKE_object.h" | #include "BKE_object.h" | ||||
| #include "BKE_animsys.h" | #include "BKE_animsys.h" | ||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "DEG_depsgraph.h" | #include "DEG_depsgraph.h" | ||||
| #include "DEG_depsgraph_query.h" | |||||
| #include "eevee_private.h" | #include "eevee_private.h" | ||||
| #include "GPU_extensions.h" | #include "GPU_extensions.h" | ||||
| #include "GPU_framebuffer.h" | #include "GPU_framebuffer.h" | ||||
| #include "GPU_texture.h" | #include "GPU_texture.h" | ||||
| #include "ED_screen.h" | #include "ED_screen.h" | ||||
| Show All 35 Lines | if (BKE_collection_engine_property_value_get_bool(props, "dof_enable")) { | ||||
| RegionView3D *rv3d = draw_ctx->rv3d; | RegionView3D *rv3d = draw_ctx->rv3d; | ||||
| if (!e_data.dof_downsample_sh) { | if (!e_data.dof_downsample_sh) { | ||||
| eevee_create_shader_depth_of_field(); | eevee_create_shader_depth_of_field(); | ||||
| } | } | ||||
| if (rv3d->persp == RV3D_CAMOB && v3d->camera) { | if (rv3d->persp == RV3D_CAMOB && v3d->camera) { | ||||
| const float *viewport_size = DRW_viewport_size_get(); | const float *viewport_size = DRW_viewport_size_get(); | ||||
| Camera *cam = (Camera *)v3d->camera->data; | Object *camera_object = DEG_get_evaluated_object(draw_ctx->depsgraph, v3d->camera); | ||||
| Camera *cam = (Camera *)camera_object->data; | |||||
| /* Retreive Near and Far distance */ | /* Retreive Near and Far distance */ | ||||
| effects->dof_near_far[0] = -cam->clipsta; | effects->dof_near_far[0] = -cam->clipsta; | ||||
| effects->dof_near_far[1] = -cam->clipend; | effects->dof_near_far[1] = -cam->clipend; | ||||
| int buffer_size[2] = {(int)viewport_size[0] / 2, (int)viewport_size[1] / 2}; | int buffer_size[2] = {(int)viewport_size[0] / 2, (int)viewport_size[1] / 2}; | ||||
| /* Reuse buffer from Bloom if available */ | /* Reuse buffer from Bloom if available */ | ||||
| Show All 32 Lines | if (rv3d->persp == RV3D_CAMOB && v3d->camera) { | ||||
| /* Parameters */ | /* Parameters */ | ||||
| /* TODO UI Options */ | /* TODO UI Options */ | ||||
| float fstop = cam->gpu_dof.fstop; | float fstop = cam->gpu_dof.fstop; | ||||
| float blades = cam->gpu_dof.num_blades; | float blades = cam->gpu_dof.num_blades; | ||||
| float rotation = cam->gpu_dof.rotation; | float rotation = cam->gpu_dof.rotation; | ||||
| float ratio = 1.0f / cam->gpu_dof.ratio; | float ratio = 1.0f / cam->gpu_dof.ratio; | ||||
| 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(v3d->camera); | float focus_dist = BKE_camera_object_dof_distance(camera_object); | ||||
| float focal_len = cam->lens; | float focal_len = cam->lens; | ||||
| UNUSED_VARS(rotation, ratio); | UNUSED_VARS(rotation, ratio); | ||||
| /* this is factor that converts to the scene scale. focal length and sensor are expressed in mm | /* 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 | * 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. | * 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). */ | * Note however that focus_distance is already in blender units and shall not be scaled here (see T48157). */ | ||||
| ▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines | |||||