Squashed commit of the following:
[blender-staging.git] / intern / cycles / kernel / closure / bsdf.h
1 /*
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.
15  */
16
17 #include "kernel/closure/bsdf_ashikhmin_velvet.h"
18 #include "kernel/closure/bsdf_diffuse.h"
19 #include "kernel/closure/bsdf_oren_nayar.h"
20 #include "kernel/closure/bsdf_phong_ramp.h"
21 #include "kernel/closure/bsdf_diffuse_ramp.h"
22 #include "kernel/closure/bsdf_microfacet.h"
23 #include "kernel/closure/bsdf_microfacet_multi.h"
24 #include "kernel/closure/bsdf_reflection.h"
25 #include "kernel/closure/bsdf_refraction.h"
26 #include "kernel/closure/bsdf_transparent.h"
27 #include "kernel/closure/bsdf_ashikhmin_shirley.h"
28 #include "kernel/closure/bsdf_toon.h"
29 #include "kernel/closure/bsdf_hair.h"
30 #include "kernel/closure/bsdf_principled_diffuse.h"
31 #include "kernel/closure/bsdf_principled_sheen.h"
32 #ifdef __SUBSURFACE__
33 #  include "kernel/closure/bssrdf.h"
34 #endif
35 #ifdef __VOLUME__
36 #  include "kernel/closure/volume.h"
37 #endif
38
39 CCL_NAMESPACE_BEGIN
40
41 ccl_device_forceinline int bsdf_sample(KernelGlobals *kg,
42                                        ShaderData *sd,
43                                        const ShaderClosure *sc,
44                                        float randu,
45                                        float randv,
46                                        float3 *eval,
47                                        float3 *omega_in,
48                                        differential3 *domega_in,
49                                        float *pdf)
50 {
51         int label;
52
53         switch(sc->type) {
54                 case CLOSURE_BSDF_DIFFUSE_ID:
55                 case CLOSURE_BSDF_BSSRDF_ID:
56                         label = bsdf_diffuse_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
57                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
58                         break;
59 #ifdef __SVM__
60                 case CLOSURE_BSDF_OREN_NAYAR_ID:
61                         label = bsdf_oren_nayar_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
62                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
63                         break;
64 #ifdef __OSL__
65                 case CLOSURE_BSDF_PHONG_RAMP_ID:
66                         label = bsdf_phong_ramp_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
67                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
68                         break;
69                 case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
70                         label = bsdf_diffuse_ramp_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
71                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
72                         break;
73 #endif
74                 case CLOSURE_BSDF_TRANSLUCENT_ID:
75                         label = bsdf_translucent_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
76                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
77                         break;
78                 case CLOSURE_BSDF_REFLECTION_ID:
79                         label = bsdf_reflection_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
80                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
81                         break;
82                 case CLOSURE_BSDF_REFRACTION_ID:
83                         label = bsdf_refraction_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
84                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
85                         break;
86                 case CLOSURE_BSDF_TRANSPARENT_ID:
87                         label = bsdf_transparent_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
88                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
89                         break;
90                 case CLOSURE_BSDF_MICROFACET_GGX_ID:
91                 case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
92                 case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
93                 case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
94                 case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
95                 case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
96                         label = bsdf_microfacet_ggx_sample(kg, sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
97                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
98                         break;
99                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
100                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
101                         label = bsdf_microfacet_multi_ggx_sample(kg, sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
102                                 eval, omega_in,  &domega_in->dx, &domega_in->dy, pdf, &sd->lcg_state);
103                         break;
104                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
105                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
106                         label = bsdf_microfacet_multi_ggx_glass_sample(kg, sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
107                                 eval, omega_in,  &domega_in->dx, &domega_in->dy, pdf, &sd->lcg_state);
108                         break;
109                 case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
110                 case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
111                 case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
112                         label = bsdf_microfacet_beckmann_sample(kg, sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
113                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
114                         break;
115                 case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
116                 case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
117                         label = bsdf_ashikhmin_shirley_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
118                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
119                         break;
120                 case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
121                         label = bsdf_ashikhmin_velvet_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
122                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
123                         break;
124                 case CLOSURE_BSDF_DIFFUSE_TOON_ID:
125                         label = bsdf_diffuse_toon_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
126                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
127                         break;
128                 case CLOSURE_BSDF_GLOSSY_TOON_ID:
129                         label = bsdf_glossy_toon_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
130                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
131                         break;
132                 case CLOSURE_BSDF_HAIR_REFLECTION_ID:
133                         label = bsdf_hair_reflection_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
134                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
135                         break;
136                 case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
137                         label = bsdf_hair_transmission_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
138                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
139                         break;
140                 case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
141                 case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID:
142                         label = bsdf_principled_diffuse_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
143                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
144                         break;
145                 case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
146                         label = bsdf_principled_sheen_sample(sc, sd->Ng, sd->I, sd->dI.dx, sd->dI.dy, randu, randv,
147                                 eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
148                         break;
149 #endif
150 #ifdef __VOLUME__
151                 case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
152                         label = volume_henyey_greenstein_sample(sc, sd->I, sd->dI.dx, sd->dI.dy, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
153                         break;
154 #endif
155                 default:
156                         label = LABEL_NONE;
157                         break;
158         }
159
160         return label;
161 }
162
163 #ifndef __KERNEL_CUDA__
164 ccl_device
165 #else
166 ccl_device_forceinline
167 #endif
168 float3 bsdf_eval(KernelGlobals *kg,
169                  ShaderData *sd,
170                  const ShaderClosure *sc,
171                  const float3 omega_in,
172                  float *pdf)
173 {
174         float3 eval;
175
176         if(dot(sd->Ng, omega_in) >= 0.0f) {
177                 switch(sc->type) {
178                         case CLOSURE_BSDF_DIFFUSE_ID:
179                         case CLOSURE_BSDF_BSSRDF_ID:
180                                 eval = bsdf_diffuse_eval_reflect(sc, sd->I, omega_in, pdf);
181                                 break;
182 #ifdef __SVM__
183                         case CLOSURE_BSDF_OREN_NAYAR_ID:
184                                 eval = bsdf_oren_nayar_eval_reflect(sc, sd->I, omega_in, pdf);
185                                 break;
186 #ifdef __OSL__
187                         case CLOSURE_BSDF_PHONG_RAMP_ID:
188                                 eval = bsdf_phong_ramp_eval_reflect(sc, sd->I, omega_in, pdf);
189                                 break;
190                         case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
191                                 eval = bsdf_diffuse_ramp_eval_reflect(sc, sd->I, omega_in, pdf);
192                                 break;
193 #endif
194                         case CLOSURE_BSDF_TRANSLUCENT_ID:
195                                 eval = bsdf_translucent_eval_reflect(sc, sd->I, omega_in, pdf);
196                                 break;
197                         case CLOSURE_BSDF_REFLECTION_ID:
198                                 eval = bsdf_reflection_eval_reflect(sc, sd->I, omega_in, pdf);
199                                 break;
200                         case CLOSURE_BSDF_REFRACTION_ID:
201                                 eval = bsdf_refraction_eval_reflect(sc, sd->I, omega_in, pdf);
202                                 break;
203                         case CLOSURE_BSDF_TRANSPARENT_ID:
204                                 eval = bsdf_transparent_eval_reflect(sc, sd->I, omega_in, pdf);
205                                 break;
206                         case CLOSURE_BSDF_MICROFACET_GGX_ID:
207                         case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
208                         case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
209                         case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
210                         case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
211                         case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
212                                 eval = bsdf_microfacet_ggx_eval_reflect(sc, sd->I, omega_in, pdf);
213                                 break;
214                         case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
215                         case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
216                                 eval = bsdf_microfacet_multi_ggx_eval_reflect(sc, sd->I, omega_in, pdf, &sd->lcg_state);
217                                 break;
218                         case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
219                         case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
220                                 eval = bsdf_microfacet_multi_ggx_glass_eval_reflect(sc, sd->I, omega_in, pdf, &sd->lcg_state);
221                                 break;
222                         case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
223                         case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
224                         case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
225                                 eval = bsdf_microfacet_beckmann_eval_reflect(sc, sd->I, omega_in, pdf);
226                                 break;
227                         case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
228                         case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
229                                 eval = bsdf_ashikhmin_shirley_eval_reflect(sc, sd->I, omega_in, pdf);
230                                 break;
231                         case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
232                                 eval = bsdf_ashikhmin_velvet_eval_reflect(sc, sd->I, omega_in, pdf);
233                                 break;
234                         case CLOSURE_BSDF_DIFFUSE_TOON_ID:
235                                 eval = bsdf_diffuse_toon_eval_reflect(sc, sd->I, omega_in, pdf);
236                                 break;
237                         case CLOSURE_BSDF_GLOSSY_TOON_ID:
238                                 eval = bsdf_glossy_toon_eval_reflect(sc, sd->I, omega_in, pdf);
239                                 break;
240                         case CLOSURE_BSDF_HAIR_REFLECTION_ID:
241                                 eval = bsdf_hair_reflection_eval_reflect(sc, sd->I, omega_in, pdf);
242                                 break;
243                         case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
244                                 eval = bsdf_hair_transmission_eval_reflect(sc, sd->I, omega_in, pdf);
245                                 break;
246                         case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
247                         case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID:
248                                 eval = bsdf_principled_diffuse_eval_reflect(sc, sd->I, omega_in, pdf);
249                                 break;
250                         case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
251                                 eval = bsdf_principled_sheen_eval_reflect(sc, sd->I, omega_in, pdf);
252                                 break;
253 #endif
254 #ifdef __VOLUME__
255                         case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
256                                 eval = volume_henyey_greenstein_eval_phase(sc, sd->I, omega_in, pdf);
257                                 break;
258 #endif
259                         default:
260                                 eval = make_float3(0.0f, 0.0f, 0.0f);
261                                 break;
262                 }
263         }
264         else {
265                 switch(sc->type) {
266                         case CLOSURE_BSDF_DIFFUSE_ID:
267                         case CLOSURE_BSDF_BSSRDF_ID:
268                                 eval = bsdf_diffuse_eval_transmit(sc, sd->I, omega_in, pdf);
269                                 break;
270 #ifdef __SVM__
271                         case CLOSURE_BSDF_OREN_NAYAR_ID:
272                                 eval = bsdf_oren_nayar_eval_transmit(sc, sd->I, omega_in, pdf);
273                                 break;
274                         case CLOSURE_BSDF_TRANSLUCENT_ID:
275                                 eval = bsdf_translucent_eval_transmit(sc, sd->I, omega_in, pdf);
276                                 break;
277                         case CLOSURE_BSDF_REFLECTION_ID:
278                                 eval = bsdf_reflection_eval_transmit(sc, sd->I, omega_in, pdf);
279                                 break;
280                         case CLOSURE_BSDF_REFRACTION_ID:
281                                 eval = bsdf_refraction_eval_transmit(sc, sd->I, omega_in, pdf);
282                                 break;
283                         case CLOSURE_BSDF_TRANSPARENT_ID:
284                                 eval = bsdf_transparent_eval_transmit(sc, sd->I, omega_in, pdf);
285                                 break;
286                         case CLOSURE_BSDF_MICROFACET_GGX_ID:
287                         case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
288                         case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
289                         case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
290                         case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
291                         case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
292                                 eval = bsdf_microfacet_ggx_eval_transmit(sc, sd->I, omega_in, pdf);
293                                 break;
294                         case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
295                         case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
296                                 eval = bsdf_microfacet_multi_ggx_eval_transmit(sc, sd->I, omega_in, pdf, &sd->lcg_state);
297                                 break;
298                         case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
299                         case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
300                                 eval = bsdf_microfacet_multi_ggx_glass_eval_transmit(sc, sd->I, omega_in, pdf, &sd->lcg_state);
301                                 break;
302                         case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
303                         case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
304                         case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
305                                 eval = bsdf_microfacet_beckmann_eval_transmit(sc, sd->I, omega_in, pdf);
306                                 break;
307                         case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
308                         case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
309                                 eval = bsdf_ashikhmin_shirley_eval_transmit(sc, sd->I, omega_in, pdf);
310                                 break;
311                         case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
312                                 eval = bsdf_ashikhmin_velvet_eval_transmit(sc, sd->I, omega_in, pdf);
313                                 break;
314                         case CLOSURE_BSDF_DIFFUSE_TOON_ID:
315                                 eval = bsdf_diffuse_toon_eval_transmit(sc, sd->I, omega_in, pdf);
316                                 break;
317                         case CLOSURE_BSDF_GLOSSY_TOON_ID:
318                                 eval = bsdf_glossy_toon_eval_transmit(sc, sd->I, omega_in, pdf);
319                                 break;
320                         case CLOSURE_BSDF_HAIR_REFLECTION_ID:
321                                 eval = bsdf_hair_reflection_eval_transmit(sc, sd->I, omega_in, pdf);
322                                 break;
323                         case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
324                                 eval = bsdf_hair_transmission_eval_transmit(sc, sd->I, omega_in, pdf);
325                                 break;
326                         case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
327                         case CLOSURE_BSDF_BSSRDF_PRINCIPLED_ID:
328                                 eval = bsdf_principled_diffuse_eval_transmit(sc, sd->I, omega_in, pdf);
329                                 break;
330                         case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
331                                 eval = bsdf_principled_sheen_eval_transmit(sc, sd->I, omega_in, pdf);
332                                 break;
333 #endif
334 #ifdef __VOLUME__
335                         case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
336                                 eval = volume_henyey_greenstein_eval_phase(sc, sd->I, omega_in, pdf);
337                                 break;
338 #endif
339                         default:
340                                 eval = make_float3(0.0f, 0.0f, 0.0f);
341                                 break;
342                 }
343         }
344
345         return eval;
346 }
347
348 ccl_device void bsdf_blur(KernelGlobals *kg, ShaderClosure *sc, float roughness)
349 {
350         /* ToDo: do we want to blur volume closures? */
351 #ifdef __SVM__
352         switch(sc->type) {
353                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
354                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
355                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
356                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
357                         bsdf_microfacet_multi_ggx_blur(sc, roughness);
358                         break;
359                 case CLOSURE_BSDF_MICROFACET_GGX_ID:
360                 case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
361                 case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
362                 case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
363                 case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
364                 case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
365                         bsdf_microfacet_ggx_blur(sc, roughness);
366                         break;
367                 case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
368                 case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
369                 case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
370                         bsdf_microfacet_beckmann_blur(sc, roughness);
371                         break;
372                 case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
373                 case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
374                         bsdf_ashikhmin_shirley_blur(sc, roughness);
375                         break;
376                 default:
377                         break;
378         }
379 #endif
380 }
381
382 ccl_device bool bsdf_merge(ShaderClosure *a, ShaderClosure *b)
383 {
384 #ifdef __SVM__
385         switch(a->type) {
386                 case CLOSURE_BSDF_TRANSPARENT_ID:
387                         return true;
388                 case CLOSURE_BSDF_DIFFUSE_ID:
389                 case CLOSURE_BSDF_BSSRDF_ID:
390                 case CLOSURE_BSDF_TRANSLUCENT_ID:
391                         return bsdf_diffuse_merge(a, b);
392                 case CLOSURE_BSDF_OREN_NAYAR_ID:
393                         return bsdf_oren_nayar_merge(a, b);
394                 case CLOSURE_BSDF_REFLECTION_ID:
395                 case CLOSURE_BSDF_REFRACTION_ID:
396                 case CLOSURE_BSDF_MICROFACET_GGX_ID:
397                 case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
398                 case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
399                 case CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID:
400                 case CLOSURE_BSDF_MICROFACET_GGX_ANISO_FRESNEL_ID:
401                 case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
402                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
403                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
404                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
405                 case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
406                 case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
407                 case CLOSURE_BSDF_MICROFACET_BECKMANN_ANISO_ID:
408                 case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
409                 case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
410                 case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ANISO_ID:
411                         return bsdf_microfacet_merge(a, b);
412                 case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
413                         return bsdf_ashikhmin_velvet_merge(a, b);
414                 case CLOSURE_BSDF_DIFFUSE_TOON_ID:
415                 case CLOSURE_BSDF_GLOSSY_TOON_ID:
416                         return bsdf_toon_merge(a, b);
417                 case CLOSURE_BSDF_HAIR_REFLECTION_ID:
418                 case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
419                         return bsdf_hair_merge(a, b);
420 #ifdef __VOLUME__
421                 case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
422                         return volume_henyey_greenstein_merge(a, b);
423 #endif
424                 default:
425                         return false;
426         }
427 #else
428         return false;
429 #endif
430 }
431
432 CCL_NAMESPACE_END
433