2 * Adapted from Open Shading Language with this license:
4 * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
7 * Modifications Copyright 2011, Blender Foundation.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the name of Sony Pictures Imageworks nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 #ifndef __OSL_CLOSURES_H__
34 #define __OSL_CLOSURES_H__
36 #include <OSL/oslclosure.h>
37 #include <OSL/oslexec.h>
38 #include <OSL/genclosure.h>
43 OSL_CLOSURE_BSDF_DIFFUSE_ID,
44 OSL_CLOSURE_BSDF_OREN_NAYAR_ID,
45 OSL_CLOSURE_BSDF_TRANSLUCENT_ID,
46 OSL_CLOSURE_BSDF_REFLECTION_ID,
47 OSL_CLOSURE_BSDF_REFRACTION_ID,
48 OSL_CLOSURE_BSDF_TRANSPARENT_ID,
49 OSL_CLOSURE_BSDF_MICROFACET_GGX_ID,
50 OSL_CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID,
51 OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_ID,
52 OSL_CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID,
53 OSL_CLOSURE_BSDF_WARD_ID,
54 OSL_CLOSURE_BSDF_ASHIKHMIN_VELVET_ID,
55 OSL_CLOSURE_BSDF_WESTIN_BACKSCATTER_ID,
56 OSL_CLOSURE_BSDF_WESTIN_SHEEN_ID,
57 OSL_CLOSURE_BSSRDF_CUBIC_ID,
58 OSL_CLOSURE_EMISSION_ID,
60 OSL_CLOSURE_BACKGROUND_ID,
61 OSL_CLOSURE_HOLDOUT_ID,
62 OSL_CLOSURE_SUBSURFACE_ID
65 extern OSL::ClosureParam bsdf_diffuse_params[];
66 extern OSL::ClosureParam bsdf_oren_nayar_params[];
67 extern OSL::ClosureParam bsdf_translucent_params[];
68 extern OSL::ClosureParam bsdf_reflection_params[];
69 extern OSL::ClosureParam bsdf_refraction_params[];
70 extern OSL::ClosureParam bsdf_transparent_params[];
71 extern OSL::ClosureParam bsdf_microfacet_ggx_params[];
72 extern OSL::ClosureParam bsdf_microfacet_ggx_refraction_params[];
73 extern OSL::ClosureParam bsdf_microfacet_beckmann_params[];
74 extern OSL::ClosureParam bsdf_microfacet_beckmann_refraction_params[];
75 extern OSL::ClosureParam bsdf_ward_params[];
76 extern OSL::ClosureParam bsdf_ashikhmin_velvet_params[];
77 extern OSL::ClosureParam bsdf_westin_backscatter_params[];
78 extern OSL::ClosureParam bsdf_westin_sheen_params[];
79 extern OSL::ClosureParam closure_bssrdf_cubic_params[];
80 extern OSL::ClosureParam closure_emission_params[];
81 extern OSL::ClosureParam closure_debug_params[];
82 extern OSL::ClosureParam closure_background_params[];
83 extern OSL::ClosureParam closure_holdout_params[];
84 extern OSL::ClosureParam closure_subsurface_params[];
86 void bsdf_diffuse_prepare(OSL::RendererServices *, int id, void *data);
87 void bsdf_oren_nayar_prepare(OSL::RendererServices *, int id, void *data);
88 void bsdf_translucent_prepare(OSL::RendererServices *, int id, void *data);
89 void bsdf_reflection_prepare(OSL::RendererServices *, int id, void *data);
90 void bsdf_refraction_prepare(OSL::RendererServices *, int id, void *data);
91 void bsdf_transparent_prepare(OSL::RendererServices *, int id, void *data);
92 void bsdf_microfacet_ggx_prepare(OSL::RendererServices *, int id, void *data);
93 void bsdf_microfacet_ggx_refraction_prepare(OSL::RendererServices *, int id, void *data);
94 void bsdf_microfacet_beckmann_prepare(OSL::RendererServices *, int id, void *data);
95 void bsdf_microfacet_beckmann_refraction_prepare(OSL::RendererServices *, int id, void *data);
96 void bsdf_ward_prepare(OSL::RendererServices *, int id, void *data);
97 void bsdf_ashikhmin_velvet_prepare(OSL::RendererServices *, int id, void *data);
98 void bsdf_westin_backscatter_prepare(OSL::RendererServices *, int id, void *data);
99 void bsdf_westin_sheen_prepare(OSL::RendererServices *, int id, void *data);
100 void closure_bssrdf_cubic_prepare(OSL::RendererServices *, int id, void *data);
101 void closure_emission_prepare(OSL::RendererServices *, int id, void *data);
102 void closure_debug_prepare(OSL::RendererServices *, int id, void *data);
103 void closure_background_prepare(OSL::RendererServices *, int id, void *data);
104 void closure_holdout_prepare(OSL::RendererServices *, int id, void *data);
105 void closure_subsurface_prepare(OSL::RendererServices *, int id, void *data);
107 #define CLOSURE_PREPARE(name, classname) \
108 void name(RendererServices *, int id, void *data) \
110 memset(data, 0, sizeof(classname)); \
111 new (data) classname(); \
116 #endif /* __OSL_CLOSURES_H__ */