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