Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_camera.h
| Show First 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | |||||
| #ifdef __RAY_DIFFERENTIALS__ | #ifdef __RAY_DIFFERENTIALS__ | ||||
| /* ray differential */ | /* ray differential */ | ||||
| float3 Ddiff = transform_direction(&cameratoworld, Pcamera); | float3 Ddiff = transform_direction(&cameratoworld, Pcamera); | ||||
| ray->dP = differential3_zero(); | ray->dP = differential3_zero(); | ||||
| ray->dD.dx = normalize(Ddiff + float4_to_float3(kernel_data.cam.dx)) - normalize(Ddiff); | ray->dD.dx = normalize(Ddiff + float4_to_float3(kernel_data.cam.dx)) - normalize(Ddiff); | ||||
| ray->dD.dy = normalize(Ddiff + float4_to_float3(kernel_data.cam.dy)) - normalize(Ddiff); | ray->dD.dy = normalize(Ddiff + float4_to_float3(kernel_data.cam.dy)) - normalize(Ddiff); | ||||
sergey: Interesting, so derivatives can't be pre-calculated even for perspective camera when spherical… | |||||
| #endif | #endif | ||||
| #ifdef __CAMERA_CLIPPING__ | #ifdef __CAMERA_CLIPPING__ | ||||
| /* clipping */ | /* clipping */ | ||||
| float3 Pclip = normalize(Pcamera); | float3 Pclip = normalize(Pcamera); | ||||
| float z_inv = 1.0f / Pclip.z; | float z_inv = 1.0f / Pclip.z; | ||||
| ray->P += kernel_data.cam.nearclip*ray->D * z_inv; | ray->P += kernel_data.cam.nearclip*ray->D * z_inv; | ||||
| ray->t = kernel_data.cam.cliplength * z_inv; | ray->t = kernel_data.cam.cliplength * z_inv; | ||||
| ▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | |||||
| #else | #else | ||||
| transform_motion_interpolate(&cameratoworld, | transform_motion_interpolate(&cameratoworld, | ||||
| (const DecompMotionTransform*)&kernel_data.cam.motion, | (const DecompMotionTransform*)&kernel_data.cam.motion, | ||||
| ray->time); | ray->time); | ||||
| #endif | #endif | ||||
| } | } | ||||
| #endif | #endif | ||||
| ray->P = transform_point(&cameratoworld, ray->P); | float3 tP = transform_point(&cameratoworld, ray->P); | ||||
| ray->D = transform_direction(&cameratoworld, ray->D); | float3 tD = transform_direction(&cameratoworld, ray->D); | ||||
| ray->P = panorama_stereo_position(kg, tD, tP); | |||||
| ray->D = panorama_stereo_direction(kg, tD, tP, ray->P); | |||||
| ray->D = normalize(ray->D); | ray->D = normalize(ray->D); | ||||
| #ifdef __RAY_DIFFERENTIALS__ | #ifdef __RAY_DIFFERENTIALS__ | ||||
| /* ray differential */ | /* ray differential */ | ||||
| ray->dP = differential3_zero(); | ray->dP = differential3_zero(); | ||||
| Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f)); | tP = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f)); | ||||
| ray->dD.dx = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D; | tD = transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y)) - ray->D; | ||||
| Pcamera = panorama_stereo_position(kg, tD, tP); | |||||
| Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f)); | ray->dD.dx = normalize(panorama_stereo_direction(kg, tD, tP, Pcamera)); | ||||
| ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D; | |||||
| tP = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f)); | |||||
| tD = transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y)) - ray->D; | |||||
| Pcamera = panorama_stereo_position(kg, tD, tP); | |||||
| ray->dD.dy = normalize(panorama_stereo_direction(kg, tD, tP, Pcamera)); | |||||
| #endif | #endif | ||||
Done Inline ActionsIf eye is STEREO_NONE then panorama_stereo_position will give same position as camera and all this code seems to be same as the case above and we can avoid this duplication? sergey: If eye is `STEREO_NONE` then `panorama_stereo_position` will give same position as camera and… | |||||
Not Done Inline ActionsCorrect, and this is what I had in a previous patch. I just tried to make the changes less intrusives (and with less impact on general performance for the non-spherical stereo use case). I will remove this, then. dfelinto: Correct, and this is what I had in a previous patch. I just tried to make the changes less… | |||||
| } | } | ||||
Not Done Inline ActionsThis chunk is same as above apart from panorama_to_direction part. Thinking loud: would it be more clear to move this to an utility function with an argument denoting whether derivatives are calculated for panorama camera? sergey: This chunk is same as above apart from `panorama_to_direction` part.
Thinking loud: would it… | |||||
| /* Common */ | /* Common */ | ||||
| ccl_device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v, | ccl_device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v, | ||||
| float lens_u, float lens_v, float time, ccl_addr_space Ray *ray) | float lens_u, float lens_v, float time, ccl_addr_space Ray *ray) | ||||
| { | { | ||||
| /* pixel filter */ | /* pixel filter */ | ||||
| int filter_table_offset = kernel_data.film.filter_table_offset; | int filter_table_offset = kernel_data.film.filter_table_offset; | ||||
| ▲ Show 20 Lines • Show All 81 Lines • Show Last 20 Lines | |||||
Interesting, so derivatives can't be pre-calculated even for perspective camera when spherical 3D is used?
If so, i think it worth sticking to a single method as it is currently (don't think it's a bottleneck, having single code base is easier for maintenance) and remove derivatived pre-calculation from camera.cpp.
Other notes:
P.S. Or maybe there is a trick to pre-calculate derivated for stereo 3d and perspective camera..