| 173 | return pdf = 0; |
| 174 | } |
| 175 | virtual float sample(const OSL::ShaderGlobals& sg, float rx, float ry, float rz, OSL::Dual2<OSL::Vec3>& wi, float& pdf) const { |
| 176 | float cosNO = -N.dot(sg.I); |
| 177 | if (cosNO > 0) { |
| 178 | // reflect the view vector |
| 179 | Vec3 R = (2 * cosNO) * N + sg.I; |
| 180 | TangentFrame tf(R); |
| 181 | float phi = 2 * float(M_PI) * rx; |
| 182 | float sp, cp; |
| 183 | OIIO::fast_sincos(phi, &sp, &cp); |
| 184 | float cosTheta = OIIO::fast_safe_pow(ry, 1 / (exponent + 1)); |
| 185 | float sinTheta2 = 1 - cosTheta * cosTheta; |
| 186 | float sinTheta = sinTheta2 > 0 ? sqrtf(sinTheta2) : 0; |
| 187 | wi = tf.get(cp * sinTheta, |
| 188 | sp * sinTheta, |
| 189 | cosTheta); // leave derivs 0? |
| 190 | float cosNI = N.dot(wi.val()); |
| 191 | if (cosNI > 0) { |
| 192 | pdf = (exponent + 1) * float(M_1_PI / 2) * OIIO::fast_safe_pow(cosTheta, exponent); |
| 193 | return cosNI * (exponent + 2) / (exponent + 1); |
| 194 | } |
| 195 | } |
| 196 | return pdf = 0; |
| 197 | } |
| 198 | }; |
| 199 | |
| 200 | struct Ward : public BSDF, WardParams { |
nothing calls this directly
no test coverage detected