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_microfacet.h"
22 #include "bsdf_reflection.h"
23 #include "bsdf_refraction.h"
24 #include "bsdf_transparent.h"
26 #include "bsdf_ward.h"
28 #include "bsdf_westin.h"
32 __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)
37 case CLOSURE_BSDF_DIFFUSE_ID:
38 label = bsdf_diffuse_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
41 case CLOSURE_BSDF_TRANSLUCENT_ID:
42 label = bsdf_translucent_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
44 case CLOSURE_BSDF_REFLECTION_ID:
45 label = bsdf_reflection_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
47 case CLOSURE_BSDF_REFRACTION_ID:
48 label = bsdf_refraction_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
50 case CLOSURE_BSDF_TRANSPARENT_ID:
51 label = bsdf_transparent_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
53 case CLOSURE_BSDF_MICROFACET_GGX_ID:
54 case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
55 label = bsdf_microfacet_ggx_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
57 case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
58 case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
59 label = bsdf_microfacet_beckmann_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
62 case CLOSURE_BSDF_WARD_ID:
63 label = bsdf_ward_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
66 case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
67 label = bsdf_ashikhmin_velvet_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
69 case CLOSURE_BSDF_WESTIN_BACKSCATTER_ID:
70 label = bsdf_westin_backscatter_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
72 case CLOSURE_BSDF_WESTIN_SHEEN_ID:
73 label = bsdf_westin_sheen_sample(sd, sc, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
84 __device float3 svm_bsdf_eval(const ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf)
88 if(dot(sd->Ng, omega_in) >= 0.0f) {
90 case CLOSURE_BSDF_DIFFUSE_ID:
91 eval = bsdf_diffuse_eval_reflect(sd, sc, sd->I, omega_in, pdf);
94 case CLOSURE_BSDF_TRANSLUCENT_ID:
95 eval = bsdf_translucent_eval_reflect(sd, sc, sd->I, omega_in, pdf);
97 case CLOSURE_BSDF_REFLECTION_ID:
98 eval = bsdf_reflection_eval_reflect(sd, sc, sd->I, omega_in, pdf);
100 case CLOSURE_BSDF_REFRACTION_ID:
101 eval = bsdf_refraction_eval_reflect(sd, sc, sd->I, omega_in, pdf);
103 case CLOSURE_BSDF_TRANSPARENT_ID:
104 eval = bsdf_transparent_eval_reflect(sd, sc, sd->I, omega_in, pdf);
106 case CLOSURE_BSDF_MICROFACET_GGX_ID:
107 case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
108 eval = bsdf_microfacet_ggx_eval_reflect(sd, sc, sd->I, omega_in, pdf);
110 case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
111 case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
112 eval = bsdf_microfacet_beckmann_eval_reflect(sd, sc, sd->I, omega_in, pdf);
115 case CLOSURE_BSDF_WARD_ID:
116 eval = bsdf_ward_eval_reflect(sd, sc, sd->I, omega_in, pdf);
119 case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
120 eval = bsdf_ashikhmin_velvet_eval_reflect(sd, sc, sd->I, omega_in, pdf);
122 case CLOSURE_BSDF_WESTIN_BACKSCATTER_ID:
123 eval = bsdf_westin_backscatter_eval_reflect(sd, sc, sd->I, omega_in, pdf);
125 case CLOSURE_BSDF_WESTIN_SHEEN_ID:
126 eval = bsdf_westin_sheen_eval_reflect(sd, sc, sd->I, omega_in, pdf);
130 eval = make_float3(0.0f, 0.0f, 0.0f);
136 case CLOSURE_BSDF_DIFFUSE_ID:
137 eval = bsdf_diffuse_eval_transmit(sd, sc, sd->I, omega_in, pdf);
140 case CLOSURE_BSDF_TRANSLUCENT_ID:
141 eval = bsdf_translucent_eval_transmit(sd, sc, sd->I, omega_in, pdf);
143 case CLOSURE_BSDF_REFLECTION_ID:
144 eval = bsdf_reflection_eval_transmit(sd, sc, sd->I, omega_in, pdf);
146 case CLOSURE_BSDF_REFRACTION_ID:
147 eval = bsdf_refraction_eval_transmit(sd, sc, sd->I, omega_in, pdf);
149 case CLOSURE_BSDF_TRANSPARENT_ID:
150 eval = bsdf_transparent_eval_transmit(sd, sc, sd->I, omega_in, pdf);
152 case CLOSURE_BSDF_MICROFACET_GGX_ID:
153 case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
154 eval = bsdf_microfacet_ggx_eval_transmit(sd, sc, sd->I, omega_in, pdf);
156 case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
157 case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
158 eval = bsdf_microfacet_beckmann_eval_transmit(sd, sc, sd->I, omega_in, pdf);
161 case CLOSURE_BSDF_WARD_ID:
162 eval = bsdf_ward_eval_transmit(sd, sc, sd->I, omega_in, pdf);
165 case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
166 eval = bsdf_ashikhmin_velvet_eval_transmit(sd, sc, sd->I, omega_in, pdf);
168 case CLOSURE_BSDF_WESTIN_BACKSCATTER_ID:
169 eval = bsdf_westin_backscatter_eval_transmit(sd, sc, sd->I, omega_in, pdf);
171 case CLOSURE_BSDF_WESTIN_SHEEN_ID:
172 eval = bsdf_westin_sheen_eval_transmit(sd, sc, sd->I, omega_in, pdf);
176 eval = make_float3(0.0f, 0.0f, 0.0f);
184 __device void svm_bsdf_blur(ShaderClosure *sc, float roughness)
187 case CLOSURE_BSDF_DIFFUSE_ID:
188 bsdf_diffuse_blur(sc, roughness);
191 case CLOSURE_BSDF_TRANSLUCENT_ID:
192 bsdf_translucent_blur(sc, roughness);
194 case CLOSURE_BSDF_REFLECTION_ID:
195 bsdf_reflection_blur(sc, roughness);
197 case CLOSURE_BSDF_REFRACTION_ID:
198 bsdf_refraction_blur(sc, roughness);
200 case CLOSURE_BSDF_TRANSPARENT_ID:
201 bsdf_transparent_blur(sc, roughness);
203 case CLOSURE_BSDF_MICROFACET_GGX_ID:
204 case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
205 bsdf_microfacet_ggx_blur(sc, roughness);
207 case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
208 case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
209 bsdf_microfacet_beckmann_blur(sc, roughness);
212 case CLOSURE_BSDF_WARD_ID:
213 bsdf_ward_blur(sc, roughness);
216 case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
217 bsdf_ashikhmin_velvet_blur(sc, roughness);
219 case CLOSURE_BSDF_WESTIN_BACKSCATTER_ID:
220 bsdf_westin_backscatter_blur(sc, roughness);
222 case CLOSURE_BSDF_WESTIN_SHEEN_ID:
223 bsdf_westin_sheen_blur(sc, roughness);