Cycles: add Ray Length output to Light Path node. This gives the distance travelled
[blender.git] / intern / cycles / kernel / kernel_shader.h
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.
17  */
18
19 /*
20  * ShaderData, used in four steps:
21  *
22  * Setup from incoming ray, sampled position and background.
23  * Execute for surface, volume or displacement.
24  * Evaluate one or more closures.
25  * Release.
26  *
27  */
28
29 #ifdef __OSL__
30
31 #include "osl_shader.h"
32
33 #else
34
35 #include "svm/bsdf.h"
36 #include "svm/emissive.h"
37 #include "svm/volume.h"
38 #include "svm/svm_bsdf.h"
39 #include "svm/svm.h"
40
41 #endif
42
43 CCL_NAMESPACE_BEGIN
44
45 /* ShaderData setup from incoming ray */
46
47 __device_inline void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
48         const Intersection *isect, const Ray *ray)
49 {
50         /* fetch triangle data */
51         int prim = kernel_tex_fetch(__prim_index, isect->prim);
52         float4 Ns = kernel_tex_fetch(__tri_normal, prim);
53         float3 Ng = make_float3(Ns.x, Ns.y, Ns.z);
54         int shader = __float_as_int(Ns.w);
55
56         /* triangle */
57 #ifdef __INSTANCING__
58         sd->object = (isect->object == ~0)? kernel_tex_fetch(__prim_object, isect->prim): isect->object;
59 #endif
60         sd->prim = prim;
61 #ifdef __UV__
62         sd->u = isect->u;
63         sd->v = isect->v;
64 #endif
65
66         /* matrices and time */
67 #ifdef __MOTION__
68         sd->ob_tfm = object_fetch_transform(kg, sd->object, ray->time, OBJECT_TRANSFORM);
69         sd->ob_itfm = object_fetch_transform(kg, sd->object, ray->time, OBJECT_INVERSE_TRANSFORM);
70
71         sd->time = ray->time;
72 #endif
73
74         /* vectors */
75         sd->P = bvh_triangle_refine(kg, sd, isect, ray);
76         sd->Ng = Ng;
77         sd->N = Ng;
78         sd->I = -ray->D;
79         sd->shader = shader;
80         sd->ray_length = isect->t;
81
82         /* smooth normal */
83         if(sd->shader & SHADER_SMOOTH_NORMAL)
84                 sd->N = triangle_smooth_normal(kg, sd->prim, sd->u, sd->v);
85
86         sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2);
87         sd->flag |= kernel_tex_fetch(__object_flag, sd->object);
88
89 #ifdef __DPDU__
90         /* dPdu/dPdv */
91         triangle_dPdudv(kg, &sd->dPdu, &sd->dPdv, sd->prim);
92 #endif
93
94 #ifdef __INSTANCING__
95         if(isect->object != ~0) {
96                 /* instance transform */
97                 object_normal_transform(kg, sd, &sd->N);
98                 object_normal_transform(kg, sd, &sd->Ng);
99 #ifdef __DPDU__
100                 object_dir_transform(kg, sd, &sd->dPdu);
101                 object_dir_transform(kg, sd, &sd->dPdv);
102 #endif
103         }
104 #endif
105
106         /* backfacing test */
107         bool backfacing = (dot(sd->Ng, sd->I) < 0.0f);
108
109         if(backfacing) {
110                 sd->flag |= SD_BACKFACING;
111                 sd->Ng = -sd->Ng;
112                 sd->N = -sd->N;
113 #ifdef __DPDU__
114                 sd->dPdu = -sd->dPdu;
115                 sd->dPdv = -sd->dPdv;
116 #endif
117         }
118
119 #ifdef __RAY_DIFFERENTIALS__
120         /* differentials */
121         differential_transfer(&sd->dP, ray->dP, ray->D, ray->dD, sd->Ng, isect->t);
122         differential_incoming(&sd->dI, ray->dD);
123         differential_dudv(&sd->du, &sd->dv, sd->dPdu, sd->dPdv, sd->dP, sd->Ng);
124 #endif
125 }
126
127 /* ShaderData setup from position sampled on mesh */
128
129 __device void shader_setup_from_sample(KernelGlobals *kg, ShaderData *sd,
130         const float3 P, const float3 Ng, const float3 I,
131         int shader, int object, int prim, float u, float v, float t, float time)
132 {
133         /* vectors */
134         sd->P = P;
135         sd->N = Ng;
136         sd->Ng = Ng;
137         sd->I = I;
138         sd->shader = shader;
139
140         /* primitive */
141 #ifdef __INSTANCING__
142         sd->object = object;
143 #endif
144         sd->prim = prim;
145 #ifdef __UV__
146         sd->u = u;
147         sd->v = v;
148 #endif
149         sd->ray_length = t;
150
151         /* detect instancing, for non-instanced the object index is -object-1 */
152 #ifdef __INSTANCING__
153         bool instanced = false;
154
155         if(sd->prim != ~0) {
156                 if(sd->object >= 0)
157                         instanced = true;
158                 else
159 #endif
160                         sd->object = ~sd->object;
161 #ifdef __INSTANCING__
162         }
163 #endif
164
165 #ifdef __MOTION__
166         sd->time = time;
167
168         sd->ob_tfm = object_fetch_transform(kg, sd->object, time, OBJECT_TRANSFORM);
169         sd->ob_itfm = object_fetch_transform(kg, sd->object, time, OBJECT_INVERSE_TRANSFORM);
170 #endif
171
172         /* smooth normal */
173         if(sd->shader & SHADER_SMOOTH_NORMAL) {
174                 sd->N = triangle_smooth_normal(kg, sd->prim, sd->u, sd->v);
175
176 #ifdef __INSTANCING__
177                 if(instanced)
178                         object_normal_transform(kg, sd, &sd->N);
179 #endif
180         }
181
182         sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2);
183         sd->flag |= kernel_tex_fetch(__object_flag, sd->object);
184
185 #ifdef __DPDU__
186         /* dPdu/dPdv */
187         if(sd->prim == ~0) {
188                 sd->dPdu = make_float3(0.0f, 0.0f, 0.0f);
189                 sd->dPdv = make_float3(0.0f, 0.0f, 0.0f);
190         }
191         else {
192                 triangle_dPdudv(kg, &sd->dPdu, &sd->dPdv, sd->prim);
193
194 #ifdef __INSTANCING__
195                 if(instanced) {
196                         object_dir_transform(kg, sd, &sd->dPdu);
197                         object_dir_transform(kg, sd, &sd->dPdv);
198                 }
199 #endif
200         }
201 #endif
202
203         /* backfacing test */
204         if(sd->prim != ~0) {
205                 bool backfacing = (dot(sd->Ng, sd->I) < 0.0f);
206
207                 if(backfacing) {
208                         sd->flag |= SD_BACKFACING;
209                         sd->Ng = -sd->Ng;
210                         sd->N = -sd->N;
211 #ifdef __DPDU__
212                         sd->dPdu = -sd->dPdu;
213                         sd->dPdv = -sd->dPdv;
214 #endif
215                 }
216         }
217
218 #ifdef __RAY_DIFFERENTIALS__
219         /* no ray differentials here yet */
220         sd->dP.dx = make_float3(0.0f, 0.0f, 0.0f);
221         sd->dP.dy = make_float3(0.0f, 0.0f, 0.0f);
222         sd->dI.dx = make_float3(0.0f, 0.0f, 0.0f);
223         sd->dI.dy = make_float3(0.0f, 0.0f, 0.0f);
224         sd->du.dx = 0.0f;
225         sd->du.dy = 0.0f;
226         sd->dv.dx = 0.0f;
227         sd->dv.dy = 0.0f;
228 #endif
229 }
230
231 /* ShaderData setup for displacement */
232
233 __device void shader_setup_from_displace(KernelGlobals *kg, ShaderData *sd,
234         int object, int prim, float u, float v)
235 {
236         float3 P, Ng, I = make_float3(0.0f, 0.0f, 0.0f);
237         int shader;
238
239         P = triangle_point_MT(kg, prim, u, v);
240         Ng = triangle_normal_MT(kg, prim, &shader);
241
242         /* force smooth shading for displacement */
243         shader |= SHADER_SMOOTH_NORMAL;
244
245         /* watch out: no instance transform currently */
246
247         shader_setup_from_sample(kg, sd, P, Ng, I, shader, object, prim, u, v, 0.0f, TIME_INVALID);
248 }
249
250 /* ShaderData setup from ray into background */
251
252 __device_inline void shader_setup_from_background(KernelGlobals *kg, ShaderData *sd, const Ray *ray)
253 {
254         /* vectors */
255         sd->P = ray->D;
256         sd->N = -sd->P;
257         sd->Ng = -sd->P;
258         sd->I = -sd->P;
259         sd->shader = kernel_data.background.shader;
260         sd->flag = kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2);
261 #ifdef __MOTION__
262         sd->time = ray->time;
263 #endif
264         sd->ray_length = 0.0f;
265
266 #ifdef __INSTANCING__
267         sd->object = ~0;
268 #endif
269         sd->prim = ~0;
270 #ifdef __UV__
271         sd->u = 0.0f;
272         sd->v = 0.0f;
273 #endif
274
275 #ifdef __DPDU__
276         /* dPdu/dPdv */
277         sd->dPdu = make_float3(0.0f, 0.0f, 0.0f);
278         sd->dPdv = make_float3(0.0f, 0.0f, 0.0f);
279 #endif
280
281 #ifdef __RAY_DIFFERENTIALS__
282         /* differentials */
283         sd->dP = ray->dD;
284         differential_incoming(&sd->dI, sd->dP);
285         sd->du.dx = 0.0f;
286         sd->du.dy = 0.0f;
287         sd->dv.dx = 0.0f;
288         sd->dv.dy = 0.0f;
289 #endif
290 }
291
292 /* BSDF */
293
294 #ifdef __MULTI_CLOSURE__
295
296 __device_inline void _shader_bsdf_multi_eval(const ShaderData *sd, const float3 omega_in, float *pdf,
297         int skip_bsdf, BsdfEval *bsdf_eval, float sum_pdf, float sum_sample_weight)
298 {
299         for(int i = 0; i< sd->num_closure; i++) {
300                 if(i == skip_bsdf)
301                         continue;
302
303                 const ShaderClosure *sc = &sd->closure[i];
304
305                 if(CLOSURE_IS_BSDF(sc->type)) {
306                         float bsdf_pdf = 0.0f;
307 #ifdef __OSL__
308                         float3 eval = OSLShader::bsdf_eval(sd, sc, omega_in, bsdf_pdf);
309 #else
310                         float3 eval = svm_bsdf_eval(sd, sc, omega_in, &bsdf_pdf);
311 #endif
312
313                         if(bsdf_pdf != 0.0f) {
314                                 bsdf_eval_accum(bsdf_eval, sc->type, eval*sc->weight);
315                                 sum_pdf += bsdf_pdf*sc->sample_weight;
316                         }
317
318                         sum_sample_weight += sc->sample_weight;
319                 }
320         }
321
322         *pdf = (sum_sample_weight > 0.0f)? sum_pdf/sum_sample_weight: 0.0f;
323 }
324
325 #endif
326
327 __device void shader_bsdf_eval(KernelGlobals *kg, const ShaderData *sd,
328         const float3 omega_in, BsdfEval *eval, float *pdf)
329 {
330 #ifdef __MULTI_CLOSURE__
331         bsdf_eval_init(eval, NBUILTIN_CLOSURES, make_float3(0.0f, 0.0f, 0.0f), kernel_data.film.use_light_pass);
332
333         return _shader_bsdf_multi_eval(sd, omega_in, pdf, -1, eval, 0.0f, 0.0f);
334 #else
335         const ShaderClosure *sc = &sd->closure;
336
337         *pdf = 0.0f;
338         *eval = svm_bsdf_eval(sd, sc, omega_in, pdf)*sc->weight;
339 #endif
340 }
341
342 __device int shader_bsdf_sample(KernelGlobals *kg, const ShaderData *sd,
343         float randu, float randv, BsdfEval *bsdf_eval,
344         float3 *omega_in, differential3 *domega_in, float *pdf)
345 {
346 #ifdef __MULTI_CLOSURE__
347         int sampled = 0;
348
349         if(sd->num_closure > 1) {
350                 /* pick a BSDF closure based on sample weights */
351                 float sum = 0.0f;
352
353                 for(sampled = 0; sampled < sd->num_closure; sampled++) {
354                         const ShaderClosure *sc = &sd->closure[sampled];
355                         
356                         if(CLOSURE_IS_BSDF(sc->type))
357                                 sum += sc->sample_weight;
358                 }
359
360                 float r = sd->randb_closure*sum;
361                 sum = 0.0f;
362
363                 for(sampled = 0; sampled < sd->num_closure; sampled++) {
364                         const ShaderClosure *sc = &sd->closure[sampled];
365                         
366                         if(CLOSURE_IS_BSDF(sc->type)) {
367                                 sum += sd->closure[sampled].sample_weight;
368
369                                 if(r <= sum)
370                                         break;
371                         }
372                 }
373
374                 if(sampled == sd->num_closure) {
375                         *pdf = 0.0f;
376                         return LABEL_NONE;
377                 }
378         }
379
380         const ShaderClosure *sc = &sd->closure[sampled];
381         int label;
382         float3 eval;
383
384         *pdf = 0.0f;
385 #ifdef __OSL__
386         label = OSLShader::bsdf_sample(sd, sc, randu, randv, eval, *omega_in, *domega_in, *pdf);
387 #else
388         label = svm_bsdf_sample(sd, sc, randu, randv, &eval, omega_in, domega_in, pdf);
389 #endif
390         if(*pdf != 0.0f) {
391                 bsdf_eval_init(bsdf_eval, sc->type, eval*sc->weight, kernel_data.film.use_light_pass);
392
393                 if(sd->num_closure > 1) {
394                         float sweight = sc->sample_weight;
395                         _shader_bsdf_multi_eval(sd, *omega_in, pdf, sampled, bsdf_eval, *pdf*sweight, sweight);
396                 }
397         }
398
399         return label;
400 #else
401         /* sample the single closure that we picked */
402         *pdf = 0.0f;
403         int label = svm_bsdf_sample(sd, &sd->closure, randu, randv, bsdf_eval, omega_in, domega_in, pdf);
404         *bsdf_eval *= sd->closure.weight;
405         return label;
406 #endif
407 }
408
409 __device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
410 {
411 #ifndef __OSL__
412 #ifdef __MULTI_CLOSURE__
413         for(int i = 0; i< sd->num_closure; i++) {
414                 ShaderClosure *sc = &sd->closure[i];
415
416                 if(CLOSURE_IS_BSDF(sc->type))
417                         svm_bsdf_blur(sc, roughness);
418         }
419 #else
420         svm_bsdf_blur(&sd->closure, roughness);
421 #endif
422 #endif
423 }
424
425 __device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
426 {
427 #ifdef __MULTI_CLOSURE__
428         float3 eval = make_float3(0.0f, 0.0f, 0.0f);
429
430         for(int i = 0; i< sd->num_closure; i++) {
431                 ShaderClosure *sc = &sd->closure[i];
432
433                 if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID) // todo: make this work for osl
434                         eval += sc->weight;
435         }
436
437         return eval;
438 #else
439         if(sd->closure.type == CLOSURE_BSDF_TRANSPARENT_ID)
440                 return sd->closure.weight;
441         else
442                 return make_float3(0.0f, 0.0f, 0.0f);
443 #endif
444 }
445
446 __device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
447 {
448 #ifdef __MULTI_CLOSURE__
449         float3 eval = make_float3(0.0f, 0.0f, 0.0f);
450
451         for(int i = 0; i< sd->num_closure; i++) {
452                 ShaderClosure *sc = &sd->closure[i];
453
454                 if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
455                         eval += sc->weight;
456         }
457
458         return eval;
459 #else
460         if(CLOSURE_IS_BSDF_DIFFUSE(sd->closure.type))
461                 return sd->closure.weight;
462         else
463                 return make_float3(0.0f, 0.0f, 0.0f);
464 #endif
465 }
466
467 __device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
468 {
469 #ifdef __MULTI_CLOSURE__
470         float3 eval = make_float3(0.0f, 0.0f, 0.0f);
471
472         for(int i = 0; i< sd->num_closure; i++) {
473                 ShaderClosure *sc = &sd->closure[i];
474
475                 if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
476                         eval += sc->weight;
477         }
478
479         return eval;
480 #else
481         if(CLOSURE_IS_BSDF_GLOSSY(sd->closure.type))
482                 return sd->closure.weight;
483         else
484                 return make_float3(0.0f, 0.0f, 0.0f);
485 #endif
486 }
487
488 __device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
489 {
490 #ifdef __MULTI_CLOSURE__
491         float3 eval = make_float3(0.0f, 0.0f, 0.0f);
492
493         for(int i = 0; i< sd->num_closure; i++) {
494                 ShaderClosure *sc = &sd->closure[i];
495
496                 if(CLOSURE_IS_BSDF_TRANSMISSION(sc->type))
497                         eval += sc->weight;
498         }
499
500         return eval;
501 #else
502         if(CLOSURE_IS_BSDF_TRANSMISSION(sd->closure.type))
503                 return sd->closure.weight;
504         else
505                 return make_float3(0.0f, 0.0f, 0.0f);
506 #endif
507 }
508
509 /* Emission */
510
511 __device float3 shader_emissive_eval(KernelGlobals *kg, ShaderData *sd)
512 {
513         float3 eval;
514 #ifdef __MULTI_CLOSURE__
515         eval = make_float3(0.0f, 0.0f, 0.0f);
516
517         for(int i = 0; i < sd->num_closure; i++) {
518                 ShaderClosure *sc = &sd->closure[i];
519
520                 if(CLOSURE_IS_EMISSION(sc->type)) {
521 #ifdef __OSL__
522                         eval += OSLShader::emissive_eval(sd)*sc->weight;
523 #else
524                         eval += svm_emissive_eval(sd, sc)*sc->weight;
525 #endif
526                 }
527         }
528 #else
529         eval = svm_emissive_eval(sd, &sd->closure)*sd->closure.weight;
530 #endif
531
532         return eval;
533 }
534
535 /* Holdout */
536
537 __device float3 shader_holdout_eval(KernelGlobals *kg, ShaderData *sd)
538 {
539 #ifdef __MULTI_CLOSURE__
540         float3 weight = make_float3(0.0f, 0.0f, 0.0f);
541
542         for(int i = 0; i < sd->num_closure; i++) {
543                 ShaderClosure *sc = &sd->closure[i];
544
545                 if(CLOSURE_IS_HOLDOUT(sc->type))
546                         weight += sc->weight;
547         }
548
549         return weight;
550 #else
551         if(sd->closure.type == CLOSURE_HOLDOUT_ID)
552                 return make_float3(1.0f, 1.0f, 1.0f);
553
554         return make_float3(0.0f, 0.0f, 0.0f);
555 #endif
556 }
557
558 /* Surface Evaluation */
559
560 __device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
561         float randb, int path_flag)
562 {
563 #ifdef __OSL__
564         OSLShader::eval_surface(kg, sd, randb, path_flag);
565 #else
566
567 #ifdef __SVM__
568         svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, randb, path_flag);
569 #else
570         bsdf_diffuse_setup(sd, &sd->closure);
571         sd->closure.weight = make_float3(0.8f, 0.8f, 0.8f);
572 #endif
573
574 #endif
575 }
576
577 /* Background Evaluation */
578
579 __device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int path_flag)
580 {
581 #ifdef __OSL__
582         return OSLShader::eval_background(kg, sd, path_flag);
583 #else
584
585 #ifdef __SVM__
586         svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, 0.0f, path_flag);
587
588 #ifdef __MULTI_CLOSURE__
589         float3 eval = make_float3(0.0f, 0.0f, 0.0f);
590
591         for(int i = 0; i< sd->num_closure; i++) {
592                 const ShaderClosure *sc = &sd->closure[i];
593
594                 if(CLOSURE_IS_BACKGROUND(sc->type))
595                         eval += sc->weight;
596         }
597
598         return eval;
599 #else
600         if(sd->closure.type == CLOSURE_BACKGROUND_ID)
601                 return sd->closure.weight;
602         else
603                 return make_float3(0.0f, 0.0f, 0.0f);
604 #endif
605
606 #else
607         return make_float3(0.8f, 0.8f, 0.8f);
608 #endif
609
610 #endif
611 }
612
613 /* Volume */
614
615 __device float3 shader_volume_eval_phase(KernelGlobals *kg, ShaderData *sd,
616         float3 omega_in, float3 omega_out)
617 {
618 #ifdef __MULTI_CLOSURE__
619         float3 eval = make_float3(0.0f, 0.0f, 0.0f);
620
621         for(int i = 0; i< sd->num_closure; i++) {
622                 const ShaderClosure *sc = &sd->closure[i];
623
624                 if(CLOSURE_IS_VOLUME(sc->type)) {
625 #ifdef __OSL__
626                         eval += OSLShader::volume_eval_phase(sd, omega_in, omega_out);
627 #else
628                         eval += volume_eval_phase(sd, sc, omega_in, omega_out);
629 #endif
630                 }
631         }
632
633         return eval;
634 #else
635         return volume_eval_phase(sd, &sd->closure, omega_in, omega_out);
636 #endif
637 }
638
639 /* Volume Evaluation */
640
641 __device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
642         float randb, int path_flag)
643 {
644 #ifdef __SVM__
645 #ifdef __OSL__
646         OSLShader::eval_volume(kg, sd, randb, path_flag);
647 #else
648         svm_eval_nodes(kg, sd, SHADER_TYPE_VOLUME, randb, path_flag);
649 #endif
650 #endif
651 }
652
653 /* Displacement Evaluation */
654
655 __device void shader_eval_displacement(KernelGlobals *kg, ShaderData *sd)
656 {
657         /* this will modify sd->P */
658 #ifdef __SVM__
659 #ifdef __OSL__
660         OSLShader::eval_displacement(kg, sd);
661 #else
662         svm_eval_nodes(kg, sd, SHADER_TYPE_DISPLACEMENT, 0.0f, 0);
663 #endif
664 #endif
665 }
666
667 /* Transparent Shadows */
668
669 #ifdef __TRANSPARENT_SHADOWS__
670 __device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect)
671 {
672         int prim = kernel_tex_fetch(__prim_index, isect->prim);
673         float4 Ns = kernel_tex_fetch(__tri_normal, prim);
674         int shader = __float_as_int(Ns.w);
675         int flag = kernel_tex_fetch(__shader_flag, (shader & SHADER_MASK)*2);
676
677         return (flag & SD_HAS_SURFACE_TRANSPARENT) != 0;
678 }
679 #endif
680
681 __device int shader_pass_id(KernelGlobals *kg, ShaderData *sd)
682 {
683         return kernel_tex_fetch(__shader_flag, (sd->shader & SHADER_MASK)*2 + 1);
684 }
685
686 /* Free ShaderData */
687
688 __device void shader_release(KernelGlobals *kg, ShaderData *sd)
689 {
690 #ifdef __OSL__
691         OSLShader::release(kg, sd);
692 #endif
693 }
694
695 CCL_NAMESPACE_END
696