Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/closure/bsdf_refraction.h
| Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| ccl_device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) | ccl_device int bsdf_refraction_sample(const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf) | ||||
| { | { | ||||
| const MicrofacetBsdf *bsdf = (const MicrofacetBsdf*)sc; | const MicrofacetBsdf *bsdf = (const MicrofacetBsdf*)sc; | ||||
| float m_eta = bsdf->ior; | float m_eta = bsdf->ior; | ||||
| float3 N = bsdf->N; | float3 N = bsdf->N; | ||||
| float3 R, T; | float3 T; | ||||
| #ifdef __RAY_DIFFERENTIALS__ | #ifdef __RAY_DIFFERENTIALS__ | ||||
| float3 dRdx, dRdy, dTdx, dTdy; | float3 dTdx, dTdy; | ||||
| #endif | #endif | ||||
| bool inside; | |||||
| float fresnel; | if(refract_dielectric(m_eta, N, I, | ||||
| fresnel = fresnel_dielectric(m_eta, N, I, &R, &T, | |||||
| #ifdef __RAY_DIFFERENTIALS__ | #ifdef __RAY_DIFFERENTIALS__ | ||||
| dIdx, dIdy, &dRdx, &dRdy, &dTdx, &dTdy, | dIdx, dIdy, &dTdx, &dTdy, | ||||
| #endif | #endif | ||||
| &inside); | &T)) | ||||
| { | |||||
| if(!inside && fresnel != 1.0f) { | |||||
| /* Some high number for MIS. */ | /* Some high number for MIS. */ | ||||
| *pdf = 1e6f; | *pdf = 1e6f; | ||||
| *eval = make_float3(1e6f, 1e6f, 1e6f); | *eval = make_float3(1e6f, 1e6f, 1e6f); | ||||
| *omega_in = T; | *omega_in = T; | ||||
| #ifdef __RAY_DIFFERENTIALS__ | #ifdef __RAY_DIFFERENTIALS__ | ||||
| *domega_in_dx = dTdx; | *domega_in_dx = dTdx; | ||||
| *domega_in_dy = dTdy; | *domega_in_dy = dTdy; | ||||
| #endif | #endif | ||||
| } | } | ||||
| return LABEL_TRANSMIT|LABEL_SINGULAR; | return LABEL_TRANSMIT|LABEL_SINGULAR; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
| #endif /* __BSDF_REFRACTION_H__ */ | #endif /* __BSDF_REFRACTION_H__ */ | ||||