~ubuntu-branches/ubuntu/utopic/blender/utopic-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2011, Blender Foundation.
3
 
 *
4
 
 * This program is free software; you can redistribute it and/or
5
 
 * modify it under the terms of the GNU General Public License
6
 
 * as published by the Free Software Foundation; either version 2
7
 
 * of the License, or (at your option) any later version.
8
 
 *
9
 
 * This program is distributed in the hope that it will be useful,
10
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
 
 * GNU General Public License for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software Foundation,
16
 
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
2
 * Copyright 2011-2013 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
17
15
 */
18
16
 
19
17
CCL_NAMESPACE_BEGIN
33
31
                eval->glossy = make_float3(0.0f, 0.0f, 0.0f);
34
32
                eval->transmission = make_float3(0.0f, 0.0f, 0.0f);
35
33
                eval->transparent = make_float3(0.0f, 0.0f, 0.0f);
 
34
                eval->subsurface = make_float3(0.0f, 0.0f, 0.0f);
36
35
 
37
36
                if(type == CLOSURE_BSDF_TRANSPARENT_ID)
38
37
                        eval->transparent = value;
40
39
                        eval->diffuse = value;
41
40
                else if(CLOSURE_IS_BSDF_GLOSSY(type))
42
41
                        eval->glossy = value;
43
 
                else
 
42
                else if(CLOSURE_IS_BSDF_TRANSMISSION(type))
44
43
                        eval->transmission = value;
 
44
                else if(CLOSURE_IS_BSDF_BSSRDF(type))
 
45
                        eval->subsurface = value;
45
46
        }
46
47
        else
47
48
                eval->diffuse = value;
58
59
                        eval->diffuse += value;
59
60
                else if(CLOSURE_IS_BSDF_GLOSSY(type))
60
61
                        eval->glossy += value;
61
 
                else
 
62
                else if(CLOSURE_IS_BSDF_TRANSMISSION(type))
62
63
                        eval->transmission += value;
 
64
                else if(CLOSURE_IS_BSDF_BSSRDF(type))
 
65
                        eval->subsurface += value;
63
66
 
64
67
                /* skipping transparent, this function is used by for eval(), will be zero then */
65
68
        }
77
80
                return is_zero(eval->diffuse)
78
81
                        && is_zero(eval->glossy)
79
82
                        && is_zero(eval->transmission)
80
 
                        && is_zero(eval->transparent);
 
83
                        && is_zero(eval->transparent)
 
84
                        && is_zero(eval->subsurface);
81
85
        }
82
86
        else
83
87
                return is_zero(eval->diffuse);
93
97
                eval->diffuse *= value;
94
98
                eval->glossy *= value;
95
99
                eval->transmission *= value;
 
100
                eval->subsurface *= value;
96
101
 
97
102
                /* skipping transparent, this function is used by for eval(), will be zero then */
98
103
        }
124
129
                L->color_diffuse = make_float3(0.0f, 0.0f, 0.0f);
125
130
                L->color_glossy = make_float3(0.0f, 0.0f, 0.0f);
126
131
                L->color_transmission = make_float3(0.0f, 0.0f, 0.0f);
 
132
                L->color_subsurface = make_float3(0.0f, 0.0f, 0.0f);
127
133
 
128
134
                L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f);
129
135
                L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f);
130
136
                L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f);
 
137
                L->direct_subsurface = make_float3(0.0f, 0.0f, 0.0f);
131
138
 
132
139
                L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f);
133
140
                L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f);
134
141
                L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f);
 
142
                L->indirect_subsurface = make_float3(0.0f, 0.0f, 0.0f);
135
143
 
136
144
                L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
137
145
                L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
138
146
                L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
 
147
                L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
139
148
 
140
149
                L->emission = make_float3(0.0f, 0.0f, 0.0f);
141
150
                L->background = make_float3(0.0f, 0.0f, 0.0f);
164
173
                        L->path_diffuse = bsdf_eval->diffuse*value;
165
174
                        L->path_glossy = bsdf_eval->glossy*value;
166
175
                        L->path_transmission = bsdf_eval->transmission*value;
 
176
                        L->path_subsurface = bsdf_eval->subsurface*value;
167
177
 
168
 
                        *throughput = L->path_diffuse + L->path_glossy + L->path_transmission;
 
178
                        *throughput = L->path_diffuse + L->path_glossy + L->path_transmission + L->path_subsurface;
169
179
                        
170
180
                        L->direct_throughput = *throughput;
171
181
                }
172
182
                else {
173
183
                        /* transparent bounce before first hit, or indirectly visible through BSDF */
174
 
                        float3 sum = (bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->transparent)*inverse_pdf;
 
184
                        float3 sum = (bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->transparent + bsdf_eval->subsurface)*inverse_pdf;
175
185
                        *throughput *= sum;
176
186
                }
177
187
        }
200
210
#endif
201
211
}
202
212
 
203
 
__device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 bsdf, float3 ao, int bounce)
 
213
__device_inline void path_radiance_accum_ao(PathRadiance *L, float3 throughput, float3 alpha, float3 bsdf, float3 ao, int bounce)
204
214
{
205
215
#ifdef __PASSES__
206
216
        if(L->use_light_pass) {
207
217
                if(bounce == 0) {
208
218
                        /* directly visible lighting */
209
219
                        L->direct_diffuse += throughput*bsdf*ao;
210
 
                        L->ao += throughput*ao;
 
220
                        L->ao += alpha*throughput*ao;
211
221
                }
212
222
                else {
213
223
                        /* indirectly visible lighting after BSDF bounce */
230
240
                        L->direct_diffuse += throughput*bsdf_eval->diffuse*shadow;
231
241
                        L->direct_glossy += throughput*bsdf_eval->glossy*shadow;
232
242
                        L->direct_transmission += throughput*bsdf_eval->transmission*shadow;
 
243
                        L->direct_subsurface += throughput*bsdf_eval->subsurface*shadow;
233
244
 
234
245
                        if(is_lamp) {
235
246
                                L->shadow.x += shadow.x*shadow_fac;
239
250
                }
240
251
                else {
241
252
                        /* indirectly visible lighting after BSDF bounce */
242
 
                        float3 sum = bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission;
 
253
                        float3 sum = bsdf_eval->diffuse + bsdf_eval->glossy + bsdf_eval->transmission + bsdf_eval->subsurface;
243
254
                        L->indirect += throughput*sum*shadow;
244
255
                }
245
256
        }
273
284
#ifdef __PASSES__
274
285
        /* this division is a bit ugly, but means we only have to keep track of
275
286
         * only a single throughput further along the path, here we recover just
276
 
         * the indirect parth that is not influenced by any particular BSDF type */
 
287
         * the indirect path that is not influenced by any particular BSDF type */
277
288
        if(L->use_light_pass) {
278
289
                L->direct_emission = safe_divide_color(L->direct_emission, L->direct_throughput);
279
290
                L->direct_diffuse += L->path_diffuse*L->direct_emission;
280
291
                L->direct_glossy += L->path_glossy*L->direct_emission;
281
292
                L->direct_transmission += L->path_transmission*L->direct_emission;
 
293
                L->direct_subsurface += L->path_subsurface*L->direct_emission;
282
294
 
283
295
                L->indirect = safe_divide_color(L->indirect, L->direct_throughput);
284
296
                L->indirect_diffuse += L->path_diffuse*L->indirect;
285
297
                L->indirect_glossy += L->path_glossy*L->indirect;
286
298
                L->indirect_transmission += L->path_transmission*L->indirect;
 
299
                L->indirect_subsurface += L->path_subsurface*L->indirect;
287
300
        }
288
301
#endif
289
302
}
295
308
                L->path_diffuse = make_float3(0.0f, 0.0f, 0.0f);
296
309
                L->path_glossy = make_float3(0.0f, 0.0f, 0.0f);
297
310
                L->path_transmission = make_float3(0.0f, 0.0f, 0.0f);
 
311
                L->path_subsurface = make_float3(0.0f, 0.0f, 0.0f);
298
312
 
299
313
                L->direct_emission = make_float3(0.0f, 0.0f, 0.0f);
300
314
                L->indirect = make_float3(0.0f, 0.0f, 0.0f);
309
323
                path_radiance_sum_indirect(L);
310
324
 
311
325
                float3 L_sum = L->emission
312
 
                        + L->direct_diffuse + L->direct_glossy + L->direct_transmission
313
 
                        + L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission;
 
326
                        + L->direct_diffuse + L->direct_glossy + L->direct_transmission + L->direct_subsurface
 
327
                        + L->indirect_diffuse + L->indirect_glossy + L->indirect_transmission + L->indirect_subsurface;
314
328
 
315
329
                if(!kernel_data.background.transparent)
316
330
                        L_sum += L->background;
337
351
                        L->direct_diffuse = make_float3(0.0f, 0.0f, 0.0f);
338
352
                        L->direct_glossy = make_float3(0.0f, 0.0f, 0.0f);
339
353
                        L->direct_transmission = make_float3(0.0f, 0.0f, 0.0f);
 
354
                        L->direct_subsurface = make_float3(0.0f, 0.0f, 0.0f);
340
355
 
341
356
                        L->indirect_diffuse = make_float3(0.0f, 0.0f, 0.0f);
342
357
                        L->indirect_glossy = make_float3(0.0f, 0.0f, 0.0f);
343
358
                        L->indirect_transmission = make_float3(0.0f, 0.0f, 0.0f);
 
359
                        L->indirect_subsurface = make_float3(0.0f, 0.0f, 0.0f);
344
360
 
345
361
                        L->emission = make_float3(0.0f, 0.0f, 0.0f);
346
362
                }
357
373
                        L->direct_diffuse *= scale;
358
374
                        L->direct_glossy *= scale;
359
375
                        L->direct_transmission *= scale;
 
376
                        L->direct_subsurface *= scale;
360
377
 
361
378
                        L->indirect_diffuse *= scale;
362
379
                        L->indirect_glossy *= scale;
363
380
                        L->indirect_transmission *= scale;
 
381
                        L->indirect_subsurface *= scale;
364
382
 
365
383
                        L->emission *= scale;
366
384
                }