Merge branch 'master' into blender2.8
[blender.git] / intern / cycles / kernel / kernel_path_common.h
1 /*
2  * Copyright 2011-2015 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "util/util_hash.h"
18
19 CCL_NAMESPACE_BEGIN
20
21 ccl_device_inline void kernel_path_trace_setup(KernelGlobals *kg,
22                                                int sample,
23                                                int x, int y,
24                                                uint *rng_hash,
25                                                ccl_addr_space Ray *ray)
26 {
27         float filter_u;
28         float filter_v;
29
30         int num_samples = kernel_data.integrator.aa_samples;
31
32         path_rng_init(kg, sample, num_samples, rng_hash, x, y, &filter_u, &filter_v);
33
34         /* sample camera ray */
35
36         float lens_u = 0.0f, lens_v = 0.0f;
37
38         if(kernel_data.cam.aperturesize > 0.0f)
39                 path_rng_2D(kg, *rng_hash, sample, num_samples, PRNG_LENS_U, &lens_u, &lens_v);
40
41         float time = 0.0f;
42
43 #ifdef __CAMERA_MOTION__
44         if(kernel_data.cam.shuttertime != -1.0f)
45                 time = path_rng_1D(kg, *rng_hash, sample, num_samples, PRNG_TIME);
46 #endif
47
48         camera_sample(kg, x, y, filter_u, filter_v, lens_u, lens_v, time, ray);
49 }
50
51 CCL_NAMESPACE_END