<commit_before>uniform float material_refraction, material_refractionIor;

vec3 refract2(vec3 viewVec, vec3 Normal, float IOR) {
    float vn = dot(viewVec, Normal);
    float k = 1.0 - IOR * IOR * (1.0 - vn * vn);
    vec3 refrVec = IOR * viewVec - (IOR * vn + sqrt(k)) * Normal;
    return refrVec;
}

void addRefraction(inout psInternalData data) {

    // use same reflection code with refraction vector
    vec3 tmp = data.reflDirW;
    vec4 tmp2 = data.reflection;
    data.reflection = vec4(0.0);
    data.reflDirW = refract2(-data.viewDirW, data.normalW, material_refractionIor);

    addReflection(data);

    data.diffuseLight = mix(data.diffuseLight, data.reflection.rgb, material_refraction);
    data.reflDirW = tmp;
    data.reflection = tmp2;
}
<commit_msg>Albedo is used to tint refraction<commit_after>uniform float material_refraction, material_refractionIor;

vec3 refract2(vec3 viewVec, vec3 Normal, float IOR) {
    float vn = dot(viewVec, Normal);
    float k = 1.0 - IOR * IOR * (1.0 - vn * vn);
    vec3 refrVec = IOR * viewVec - (IOR * vn + sqrt(k)) * Normal;
    return refrVec;
}

void addRefraction(inout psInternalData data) {

    // use same reflection code with refraction vector
    vec3 tmp = data.reflDirW;
    vec4 tmp2 = data.reflection;
    data.reflection = vec4(0.0);
    data.reflDirW = refract2(-data.viewDirW, data.normalW, material_refractionIor);

    addReflection(data);

    data.diffuseLight = mix(data.diffuseLight, data.reflection.rgb * data.albedo, material_refraction);
    data.reflDirW = tmp;
    data.reflection = tmp2;
}

{'fraction_non_alphanumeric': 0.11026615969581749, 'fraction_numerical': 0.021546261089987327, 'mean_word_length': 3.5768115942028986, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '815265', 'n_tokens_mistral': 572, 'n_tokens_neox': 555, 'n_words': 136}