2
* Copyright 2011, Blender Foundation.
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.
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.
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.
19
#include "bsdf_ashikhmin_velvet.h"
20
#include "bsdf_diffuse.h"
21
#include "bsdf_oren_nayar.h"
22
#include "bsdf_microfacet.h"
23
#include "bsdf_reflection.h"
24
#include "bsdf_refraction.h"
25
#include "bsdf_transparent.h"
27
#include "bsdf_ward.h"
29
#include "bsdf_westin.h"
33
__device int svm_bsdf_sample(const ShaderData *sd, const ShaderClosure *sc, float randu, float randv, float3 *eval, float3 *omega_in, differential3 *domega_in, float *pdf)
38
case CLOSURE_BSDF_DIFFUSE_ID:
39
label = bsdf_diffuse_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
42
case CLOSURE_BSDF_OREN_NAYAR_ID:
43
label = bsdf_oren_nayar_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
45
case CLOSURE_BSDF_TRANSLUCENT_ID:
46
label = bsdf_translucent_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
48
case CLOSURE_BSDF_REFLECTION_ID:
49
label = bsdf_reflection_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
51
case CLOSURE_BSDF_REFRACTION_ID:
52
label = bsdf_refraction_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
54
case CLOSURE_BSDF_TRANSPARENT_ID:
55
label = bsdf_transparent_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
57
case CLOSURE_BSDF_MICROFACET_GGX_ID:
58
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
59
label = bsdf_microfacet_ggx_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
61
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
62
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
63
label = bsdf_microfacet_beckmann_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
66
case CLOSURE_BSDF_WARD_ID:
67
label = bsdf_ward_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
70
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
71
label = bsdf_ashikhmin_velvet_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
73
case CLOSURE_BSDF_WESTIN_BACKSCATTER_ID:
74
label = bsdf_westin_backscatter_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
76
case CLOSURE_BSDF_WESTIN_SHEEN_ID:
77
label = bsdf_westin_sheen_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
88
__device float3 svm_bsdf_eval(const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf)
92
if(dot(sd->Ng, omega_in) >= 0.0f) {
94
case CLOSURE_BSDF_DIFFUSE_ID:
95
eval = bsdf_diffuse_eval_reflect(sd, sc, sd->I, omega_in, pdf);
98
case CLOSURE_BSDF_OREN_NAYAR_ID:
99
eval = bsdf_oren_nayar_eval_reflect(sd, sc, sd->I, omega_in, pdf);
101
case CLOSURE_BSDF_TRANSLUCENT_ID:
102
eval = bsdf_translucent_eval_reflect(sd, sc, sd->I, omega_in, pdf);
104
case CLOSURE_BSDF_REFLECTION_ID:
105
eval = bsdf_reflection_eval_reflect(sd, sc, sd->I, omega_in, pdf);
107
case CLOSURE_BSDF_REFRACTION_ID:
108
eval = bsdf_refraction_eval_reflect(sd, sc, sd->I, omega_in, pdf);
110
case CLOSURE_BSDF_TRANSPARENT_ID:
111
eval = bsdf_transparent_eval_reflect(sd, sc, sd->I, omega_in, pdf);
113
case CLOSURE_BSDF_MICROFACET_GGX_ID:
114
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
115
eval = bsdf_microfacet_ggx_eval_reflect(sd, sc, sd->I, omega_in, pdf);
117
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
118
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
119
eval = bsdf_microfacet_beckmann_eval_reflect(sd, sc, sd->I, omega_in, pdf);
122
case CLOSURE_BSDF_WARD_ID:
123
eval = bsdf_ward_eval_reflect(sd, sc, sd->I, omega_in, pdf);
126
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
127
eval = bsdf_ashikhmin_velvet_eval_reflect(sd, sc, sd->I, omega_in, pdf);
129
case CLOSURE_BSDF_WESTIN_BACKSCATTER_ID:
130
eval = bsdf_westin_backscatter_eval_reflect(sd, sc, sd->I, omega_in, pdf);
132
case CLOSURE_BSDF_WESTIN_SHEEN_ID:
133
eval = bsdf_westin_sheen_eval_reflect(sd, sc, sd->I, omega_in, pdf);
137
eval = make_float3(0.0f, 0.0f, 0.0f);
143
case CLOSURE_BSDF_DIFFUSE_ID:
144
eval = bsdf_diffuse_eval_transmit(sd, sc, sd->I, omega_in, pdf);
147
case CLOSURE_BSDF_OREN_NAYAR_ID:
148
eval = bsdf_oren_nayar_eval_transmit(sd, sc, sd->I, omega_in, pdf);
150
case CLOSURE_BSDF_TRANSLUCENT_ID:
151
eval = bsdf_translucent_eval_transmit(sd, sc, sd->I, omega_in, pdf);
153
case CLOSURE_BSDF_REFLECTION_ID:
154
eval = bsdf_reflection_eval_transmit(sd, sc, sd->I, omega_in, pdf);
156
case CLOSURE_BSDF_REFRACTION_ID:
157
eval = bsdf_refraction_eval_transmit(sd, sc, sd->I, omega_in, pdf);
159
case CLOSURE_BSDF_TRANSPARENT_ID:
160
eval = bsdf_transparent_eval_transmit(sd, sc, sd->I, omega_in, pdf);
162
case CLOSURE_BSDF_MICROFACET_GGX_ID:
163
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
164
eval = bsdf_microfacet_ggx_eval_transmit(sd, sc, sd->I, omega_in, pdf);
166
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
167
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
168
eval = bsdf_microfacet_beckmann_eval_transmit(sd, sc, sd->I, omega_in, pdf);
171
case CLOSURE_BSDF_WARD_ID:
172
eval = bsdf_ward_eval_transmit(sd, sc, sd->I, omega_in, pdf);
175
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
176
eval = bsdf_ashikhmin_velvet_eval_transmit(sd, sc, sd->I, omega_in, pdf);
178
case CLOSURE_BSDF_WESTIN_BACKSCATTER_ID:
179
eval = bsdf_westin_backscatter_eval_transmit(sd, sc, sd->I, omega_in, pdf);
181
case CLOSURE_BSDF_WESTIN_SHEEN_ID:
182
eval = bsdf_westin_sheen_eval_transmit(sd, sc, sd->I, omega_in, pdf);
186
eval = make_float3(0.0f, 0.0f, 0.0f);
194
__device void svm_bsdf_blur(ShaderClosure *sc, float roughness)
197
case CLOSURE_BSDF_DIFFUSE_ID:
198
bsdf_diffuse_blur(sc, roughness);
201
case CLOSURE_BSDF_OREN_NAYAR_ID:
202
bsdf_oren_nayar_blur(sc, roughness);
204
case CLOSURE_BSDF_TRANSLUCENT_ID:
205
bsdf_translucent_blur(sc, roughness);
207
case CLOSURE_BSDF_REFLECTION_ID:
208
bsdf_reflection_blur(sc, roughness);
210
case CLOSURE_BSDF_REFRACTION_ID:
211
bsdf_refraction_blur(sc, roughness);
213
case CLOSURE_BSDF_TRANSPARENT_ID:
214
bsdf_transparent_blur(sc, roughness);
216
case CLOSURE_BSDF_MICROFACET_GGX_ID:
217
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
218
bsdf_microfacet_ggx_blur(sc, roughness);
220
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
221
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
222
bsdf_microfacet_beckmann_blur(sc, roughness);
225
case CLOSURE_BSDF_WARD_ID:
226
bsdf_ward_blur(sc, roughness);
229
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
230
bsdf_ashikhmin_velvet_blur(sc, roughness);
232
case CLOSURE_BSDF_WESTIN_BACKSCATTER_ID:
233
bsdf_westin_backscatter_blur(sc, roughness);
235
case CLOSURE_BSDF_WESTIN_SHEEN_ID:
236
bsdf_westin_sheen_blur(sc, roughness);