Entry 5992

Kajiya-Kay BRDF

   

Submitted by anonymous on Aug. 11, 2010 at 7:20 a.m.
Language: GLSL. Code size: 806 bytes.

/// \brief Diffuse term in Kajiya-Kay BRDF.
/// color_diffuse / pi
uniform vec4 diffuse_term;

/// \brief Specular term in Kajiya-Kay BRDF.
/// color_specular / pi
uniform vec4 specular_term;

/// \brief Roughness exponent in Kajiya-Kay BRDF.
uniform float specular_exp;

/// \brief Kajiya-Kay %BRDF (also known as Banks %BRDF).
vec4
kajiya_kay_brdf(
        in vec3 grain,
        in vec3 light_in,
        in vec3 light_out) {
    float odotg = dot(light_out, grain);
    float idotg = dot(light_in, grain);
    // Cosines are clamped to range [0, 1].
    float cos_diff = sqrt(1 - pow(idotg, 2));
    float cos_spec = max(sqrt(1  - pow(odotg, 2)) * cos_diff - odotg * idotg, 0);
    return
        diffuse_term * cos_diff +
        specular_term * pow(cos_spec, specular_exp);
}

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).