~ubuntu-branches/ubuntu/saucy/blender/saucy-proposed

« back to all changes in this revision

Viewing changes to intern/cycles/kernel/kernel_camera.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        /* transform ray from camera to world */
64
64
        Transform cameratoworld = kernel_data.cam.cameratoworld;
65
65
 
 
66
#ifdef __CAMERA_MOTION__
 
67
        if(kernel_data.cam.have_motion)
 
68
                transform_motion_interpolate(&cameratoworld, (const DecompMotionTransform*)&kernel_data.cam.motion, ray->time);
 
69
#endif
 
70
 
66
71
        ray->P = transform_point(&cameratoworld, ray->P);
67
72
        ray->D = transform_direction(&cameratoworld, ray->D);
68
73
        ray->D = normalize(ray->D);
101
106
        /* transform ray from camera to world */
102
107
        Transform cameratoworld = kernel_data.cam.cameratoworld;
103
108
 
 
109
#ifdef __CAMERA_MOTION__
 
110
        if(kernel_data.cam.have_motion)
 
111
                transform_motion_interpolate(&cameratoworld, (const DecompMotionTransform*)&kernel_data.cam.motion, ray->time);
 
112
#endif
 
113
 
104
114
        ray->P = transform_point(&cameratoworld, ray->P);
105
115
        ray->D = transform_direction(&cameratoworld, ray->D);
106
116
        ray->D = normalize(ray->D);
122
132
#endif
123
133
}
124
134
 
125
 
/* Environment Camera */
 
135
/* Panorama Camera */
126
136
 
127
 
__device void camera_sample_environment(KernelGlobals *kg, float raster_x, float raster_y, Ray *ray)
 
137
__device void camera_sample_panorama(KernelGlobals *kg, float raster_x, float raster_y, float lens_u, float lens_v, Ray *ray)
128
138
{
129
139
        Transform rastertocamera = kernel_data.cam.rastertocamera;
130
140
        float3 Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y, 0.0f));
131
141
 
132
142
        /* create ray form raster position */
133
 
        ray->P = make_float3(0.0, 0.0f, 0.0f);
134
 
        ray->D = equirectangular_to_direction(Pcamera.x, Pcamera.y);
 
143
        ray->P = make_float3(0.0f, 0.0f, 0.0f);
 
144
 
 
145
#ifdef __CAMERA_CLIPPING__
 
146
        /* clipping */
 
147
        ray->t = kernel_data.cam.cliplength;
 
148
#else
 
149
        ray->t = FLT_MAX;
 
150
#endif
 
151
 
 
152
        ray->D = panorama_to_direction(kg, Pcamera.x, Pcamera.y);
 
153
 
 
154
        /* modify ray for depth of field */
 
155
        float aperturesize = kernel_data.cam.aperturesize;
 
156
 
 
157
        if(aperturesize > 0.0f) {
 
158
                /* sample point on aperture */
 
159
                float2 lensuv = camera_sample_aperture(kg, lens_u, lens_v)*aperturesize;
 
160
 
 
161
                /* compute point on plane of focus */
 
162
                float3 D = normalize(ray->D);
 
163
                float3 Pfocus = D * kernel_data.cam.focaldistance;
 
164
 
 
165
                /* calculate orthonormal coordinates perpendicular to D */
 
166
                float3 U, V;
 
167
                make_orthonormals(D, &U, &V);
 
168
 
 
169
                /* update ray for effect of lens */
 
170
                ray->P = U * lensuv.x + V * lensuv.y;
 
171
                ray->D = normalize(Pfocus - ray->P);
 
172
        }
 
173
 
 
174
        /* indicates ray should not receive any light, outside of the lens */
 
175
        if(len_squared(ray->D) == 0.0f) {
 
176
                ray->t = 0.0f;
 
177
                return;
 
178
        }
135
179
 
136
180
        /* transform ray from camera to world */
137
181
        Transform cameratoworld = kernel_data.cam.cameratoworld;
138
182
 
 
183
#ifdef __CAMERA_MOTION__
 
184
        if(kernel_data.cam.have_motion)
 
185
                transform_motion_interpolate(&cameratoworld, (const DecompMotionTransform*)&kernel_data.cam.motion, ray->time);
 
186
#endif
 
187
 
139
188
        ray->P = transform_point(&cameratoworld, ray->P);
140
189
        ray->D = transform_direction(&cameratoworld, ray->D);
141
190
        ray->D = normalize(ray->D);
146
195
        ray->dP.dy = make_float3(0.0f, 0.0f, 0.0f);
147
196
 
148
197
        Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x + 1.0f, raster_y, 0.0f));
149
 
        ray->dD.dx = normalize(transform_direction(&cameratoworld, equirectangular_to_direction(Pcamera.x, Pcamera.y))) - ray->D;
 
198
        ray->dD.dx = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D;
150
199
 
151
200
        Pcamera = transform_perspective(&rastertocamera, make_float3(raster_x, raster_y + 1.0f, 0.0f));
152
 
        ray->dD.dy = normalize(transform_direction(&cameratoworld, equirectangular_to_direction(Pcamera.x, Pcamera.y))) - ray->D;
153
 
#endif
154
 
 
155
 
#ifdef __CAMERA_CLIPPING__
156
 
        /* clipping */
157
 
        ray->t = kernel_data.cam.cliplength;
158
 
#else
159
 
        ray->t = FLT_MAX;
 
201
        ray->dD.dy = normalize(transform_direction(&cameratoworld, panorama_to_direction(kg, Pcamera.x, Pcamera.y))) - ray->D;
160
202
#endif
161
203
}
162
204
 
163
205
/* Common */
164
206
 
165
 
__device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v, float lens_u, float lens_v, Ray *ray)
 
207
__device void camera_sample(KernelGlobals *kg, int x, int y, float filter_u, float filter_v,
 
208
        float lens_u, float lens_v, float time, Ray *ray)
166
209
{
167
210
        /* pixel filter */
168
211
        float raster_x = x + kernel_tex_interp(__filter_table, filter_u, FILTER_TABLE_SIZE);
169
212
        float raster_y = y + kernel_tex_interp(__filter_table, filter_v, FILTER_TABLE_SIZE);
170
213
 
 
214
#ifdef __CAMERA_MOTION__
171
215
        /* motion blur */
172
 
        //ray->time = lerp(time_t, kernel_data.cam.shutter_open, kernel_data.cam.shutter_close);
 
216
        if(kernel_data.cam.shuttertime == -1.0f)
 
217
                ray->time = TIME_INVALID;
 
218
        else
 
219
                ray->time = 0.5f + 0.5f*(time - 0.5f)*kernel_data.cam.shuttertime;
 
220
#endif
173
221
 
174
222
        /* sample */
175
223
        if(kernel_data.cam.type == CAMERA_PERSPECTIVE)
177
225
        else if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
178
226
                camera_sample_orthographic(kg, raster_x, raster_y, ray);
179
227
        else
180
 
                camera_sample_environment(kg, raster_x, raster_y, ray);
 
228
                camera_sample_panorama(kg, raster_x, raster_y, lens_u, lens_v, ray);
 
229
}
 
230
 
 
231
/* Utilities */
 
232
 
 
233
__device_inline float camera_distance(KernelGlobals *kg, float3 P)
 
234
{
 
235
        Transform cameratoworld = kernel_data.cam.cameratoworld;
 
236
        float3 camP = make_float3(cameratoworld.x.w, cameratoworld.y.w, cameratoworld.z.w);
 
237
 
 
238
        if(kernel_data.cam.type == CAMERA_ORTHOGRAPHIC) {
 
239
                float3 camD = make_float3(cameratoworld.x.z, cameratoworld.y.z, cameratoworld.z.z);
 
240
                return fabsf(dot((P - camP), camD));
 
241
        }
 
242
        else
 
243
                return len(P - camP);
181
244
}
182
245
 
183
246
CCL_NAMESPACE_END