Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_camera.h
| Show All 40 Lines | ccl_device float2 camera_sample_aperture(ccl_constant KernelCamera *cam, float u, float v) | ||||
| } | } | ||||
| /* anamorphic lens bokeh */ | /* anamorphic lens bokeh */ | ||||
| bokeh.x *= cam->inv_aperture_ratio; | bokeh.x *= cam->inv_aperture_ratio; | ||||
| return bokeh; | return bokeh; | ||||
| } | } | ||||
| ccl_device void camera_sample_perspective(ccl_global const KernelGlobals *ccl_restrict kg, | ccl_device void camera_sample_perspective(KernelGlobals kg, | ||||
| float raster_x, | float raster_x, | ||||
| float raster_y, | float raster_y, | ||||
| float lens_u, | float lens_u, | ||||
| float lens_v, | float lens_v, | ||||
| ccl_private Ray *ray) | ccl_private Ray *ray) | ||||
| { | { | ||||
| /* create ray form raster position */ | /* create ray form raster position */ | ||||
| ProjectionTransform rastertocamera = kernel_data.cam.rastertocamera; | ProjectionTransform rastertocamera = kernel_data.cam.rastertocamera; | ||||
| ▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | #ifdef __CAMERA_CLIPPING__ | ||||
| ray->dP += nearclip * ray->dD; | ray->dP += nearclip * ray->dD; | ||||
| ray->t = kernel_data.cam.cliplength * z_inv; | ray->t = kernel_data.cam.cliplength * z_inv; | ||||
| #else | #else | ||||
| ray->t = FLT_MAX; | ray->t = FLT_MAX; | ||||
| #endif | #endif | ||||
| } | } | ||||
| /* Orthographic Camera */ | /* Orthographic Camera */ | ||||
| ccl_device void camera_sample_orthographic(ccl_global const KernelGlobals *ccl_restrict kg, | ccl_device void camera_sample_orthographic(KernelGlobals kg, | ||||
| float raster_x, | float raster_x, | ||||
| float raster_y, | float raster_y, | ||||
| float lens_u, | float lens_u, | ||||
| float lens_v, | float lens_v, | ||||
| ccl_private Ray *ray) | ccl_private Ray *ray) | ||||
| { | { | ||||
| /* create ray form raster position */ | /* create ray form raster position */ | ||||
| ProjectionTransform rastertocamera = kernel_data.cam.rastertocamera; | ProjectionTransform rastertocamera = kernel_data.cam.rastertocamera; | ||||
| ▲ Show 20 Lines • Show All 168 Lines • ▼ Show 20 Lines | #ifdef __CAMERA_CLIPPING__ | ||||
| ray->t = cam->cliplength; | ray->t = cam->cliplength; | ||||
| #else | #else | ||||
| ray->t = FLT_MAX; | ray->t = FLT_MAX; | ||||
| #endif | #endif | ||||
| } | } | ||||
| /* Common */ | /* Common */ | ||||
| ccl_device_inline void camera_sample(ccl_global const KernelGlobals *ccl_restrict kg, | ccl_device_inline void camera_sample(KernelGlobals kg, | ||||
| int x, | int x, | ||||
| int y, | int y, | ||||
| float filter_u, | float filter_u, | ||||
| float filter_v, | float filter_v, | ||||
| float lens_u, | float lens_u, | ||||
| float lens_v, | float lens_v, | ||||
| float time, | float time, | ||||
| ccl_private Ray *ray) | ccl_private Ray *ray) | ||||
| ▲ Show 20 Lines • Show All 57 Lines • ▼ Show 20 Lines | |||||
| #else | #else | ||||
| camera_sample_panorama(&kernel_data.cam, raster_x, raster_y, lens_u, lens_v, ray); | camera_sample_panorama(&kernel_data.cam, raster_x, raster_y, lens_u, lens_v, ray); | ||||
| #endif | #endif | ||||
| } | } | ||||
| } | } | ||||
| /* Utilities */ | /* Utilities */ | ||||
| ccl_device_inline float3 camera_position(ccl_global const KernelGlobals *kg) | ccl_device_inline float3 camera_position(KernelGlobals kg) | ||||
| { | { | ||||
| Transform cameratoworld = kernel_data.cam.cameratoworld; | Transform cameratoworld = kernel_data.cam.cameratoworld; | ||||
| return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); | return make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); | ||||
| } | } | ||||
| ccl_device_inline float camera_distance(ccl_global const KernelGlobals *kg, float3 P) | ccl_device_inline float camera_distance(KernelGlobals kg, float3 P) | ||||
| { | { | ||||
| Transform cameratoworld = kernel_data.cam.cameratoworld; | Transform cameratoworld = kernel_data.cam.cameratoworld; | ||||
| float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); | float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); | ||||
| if (kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) { | if (kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) { | ||||
| float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z); | float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z); | ||||
| return fabsf(dot((P - camP), camD)); | return fabsf(dot((P - camP), camD)); | ||||
| } | } | ||||
| else { | else { | ||||
| return len(P - camP); | return len(P - camP); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline float camera_z_depth(ccl_global const KernelGlobals *kg, float3 P) | ccl_device_inline float camera_z_depth(KernelGlobals kg, float3 P) | ||||
| { | { | ||||
| if (kernel_data.cam.type != CAMERA_PANORAMA) { | if (kernel_data.cam.type != CAMERA_PANORAMA) { | ||||
| Transform worldtocamera = kernel_data.cam.worldtocamera; | Transform worldtocamera = kernel_data.cam.worldtocamera; | ||||
| return transform_point(&worldtocamera, P).z; | return transform_point(&worldtocamera, P).z; | ||||
| } | } | ||||
| else { | else { | ||||
| Transform cameratoworld = kernel_data.cam.cameratoworld; | Transform cameratoworld = kernel_data.cam.cameratoworld; | ||||
| float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); | float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); | ||||
| return len(P - camP); | return len(P - camP); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline float3 camera_direction_from_point(ccl_global const KernelGlobals *kg, float3 P) | ccl_device_inline float3 camera_direction_from_point(KernelGlobals kg, float3 P) | ||||
| { | { | ||||
| Transform cameratoworld = kernel_data.cam.cameratoworld; | Transform cameratoworld = kernel_data.cam.cameratoworld; | ||||
| if (kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) { | if (kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) { | ||||
| float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z); | float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z); | ||||
| return -camD; | return -camD; | ||||
| } | } | ||||
| else { | else { | ||||
| float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); | float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w); | ||||
| return normalize(camP - P); | return normalize(camP - P); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline float3 camera_world_to_ndc(ccl_global const KernelGlobals *kg, | ccl_device_inline float3 camera_world_to_ndc(KernelGlobals kg, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| float3 P) | float3 P) | ||||
| { | { | ||||
| if (kernel_data.cam.type != CAMERA_PANORAMA) { | if (kernel_data.cam.type != CAMERA_PANORAMA) { | ||||
| /* perspective / ortho */ | /* perspective / ortho */ | ||||
| if (sd->object == PRIM_NONE && kernel_data.cam.type == CAMERA_PERSPECTIVE) | if (sd->object == PRIM_NONE && kernel_data.cam.type == CAMERA_PERSPECTIVE) | ||||
| P += camera_position(kg); | P += camera_position(kg); | ||||
| Show All 19 Lines | |||||