pub fn fr_dielectric(cos_theta_i: Float, eta_i: Float, eta_t: Float) -> Float {
    let mut cos_theta_i = clamp_t(cos_theta_i, -1.0, 1.0);
    // potentially swap indices of refraction
    let entering: bool = cos_theta_i > 0.0;
    // use local copies because of potential swap (otherwise eta_i and
    // eta_t would have to be mutable)
    let mut local_eta_i = eta_i;
    let mut local_eta_t = eta_t;
    if !entering {
        std::mem::swap(&mut local_eta_i, &mut local_eta_t);
        cos_theta_i = cos_theta_i.abs();
    }
    // compute _cos_theta_t_ using Snell's law
    let sin_theta_i: Float = (0.0 as Float)
        .max(1.0 as Float - cos_theta_i * cos_theta_i)
        .sqrt();
    let sin_theta_t: Float = local_eta_i / local_eta_t * sin_theta_i;
    // handle total internal reflection
    if sin_theta_t >= 1.0 as Float {
        return 1.0 as Float;
    }
    let cos_theta_t: Float = (0.0 as Float)
        .max(1.0 as Float - sin_theta_t * sin_theta_t)
        .sqrt();
    let r_parl: Float = ((local_eta_t * cos_theta_i) - (local_eta_i * cos_theta_t))
        / ((local_eta_t * cos_theta_i) + (local_eta_i * cos_theta_t));
    let r_perp: Float = ((local_eta_i * cos_theta_i) - (local_eta_t * cos_theta_t))
        / ((local_eta_i * cos_theta_i) + (local_eta_t * cos_theta_t));
    (r_parl * r_parl + r_perp * r_perp) / 2.0
}
/// Computes the Fresnel reflection formula for dielectric materials
/// and unpolarized light.
Computes the Fresnel reflection formula for dielectric materials
and unpolarized light.
Computes the Fresnel reflection formula for dielectric materials and unpolarized light .
pub fn fr_dielectric(cos_theta_i: Float, eta_i: Float, eta_t: Float) -> Float {
    let mut cos_theta_i = clamp_t(cos_theta_i, -1.0, 1.0);
    // potentially swap indices of refraction
    let entering: bool = cos_theta_i > 0.0;
    // use local copies because of potential swap (otherwise eta_i and
    // eta_t would have to be mutable)
    let mut local_eta_i = eta_i;
    let mut local_eta_t = eta_t;
    if !entering {
        std::mem::swap(&mut local_eta_i, &mut local_eta_t);
        cos_theta_i = cos_theta_i.abs();
    }
    // compute _cos_theta_t_ using Snell's law
    let sin_theta_i: Float = (0.0 as Float)
        .max(1.0 as Float - cos_theta_i * cos_theta_i)
        .sqrt();
    let sin_theta_t: Float = local_eta_i / local_eta_t * sin_theta_i;
    // handle total internal reflection
    if sin_theta_t >= 1.0 as Float {
        return 1.0 as Float;
    }
    let cos_theta_t: Float = (0.0 as Float)
        .max(1.0 as Float - sin_theta_t * sin_theta_t)
        .sqrt();
    let r_parl: Float = ((local_eta_t * cos_theta_i) - (local_eta_i * cos_theta_t))
        / ((local_eta_t * cos_theta_i) + (local_eta_i * cos_theta_t));
    let r_perp: Float = ((local_eta_i * cos_theta_i) - (local_eta_t * cos_theta_t))
        / ((local_eta_i * cos_theta_i) + (local_eta_t * cos_theta_t));
    (r_parl * r_parl + r_perp * r_perp) / 2.0
}
pub fn fr_dielectric ( cos_theta_i : Float , eta_i : Float , eta_t : Float ) -> Float { let mut cos_theta_i = clamp_t ( cos_theta_i , - 1.0 , 1.0 ) ; // potentially swap indices of refraction let entering : bool = cos_theta_i > 0.0 ; // use local copies because of potential swap (otherwise eta_i and // eta_t would have to be mutable) let mut local_eta_i = eta_i ; let mut local_eta_t = eta_t ; if ! entering { std :: mem :: swap ( & mut local_eta_i , & mut local_eta_t ) ; cos_theta_i = cos_theta_i . abs ( ) ; } // compute _cos_theta_t_ using Snell's law let sin_theta_i : Float = ( 0.0 as Float ) . max ( 1.0 as Float - cos_theta_i * cos_theta_i ) . sqrt ( ) ; let sin_theta_t : Float = local_eta_i / local_eta_t * sin_theta_i ; // handle total internal reflection if sin_theta_t >= 1.0 as Float { return 1.0 as Float ; } let cos_theta_t : Float = ( 0.0 as Float ) . max ( 1.0 as Float - sin_theta_t * sin_theta_t ) . sqrt ( ) ; let r_parl : Float = ( ( local_eta_t * cos_theta_i ) - ( local_eta_i * cos_theta_t ) ) / ( ( local_eta_t * cos_theta_i ) + ( local_eta_i * cos_theta_t ) ) ; let r_perp : Float = ( ( local_eta_i * cos_theta_i ) - ( local_eta_t * cos_theta_t ) ) / ( ( local_eta_i * cos_theta_i ) + ( local_eta_t * cos_theta_t ) ) ; ( r_parl * r_parl + r_perp * r_perp ) / 2.0 }
Computes the Fresnel reflection formula for dielectric materials
and unpolarized light.
Computes the Fresnel reflection formula for dielectric materials and unpolarized light .
cos_theta_i
Float
eta_i
Float
eta_t
Float