<commit_before>//
//  Shader.cpp
//  COMP575_HW01
//
//  Created by <NAME> on 9/18/14.
//  Copyright (c) 2014 <NAME>. All rights reserved.
//

#include "Shader.h"

float SpecularPower;
float GammaValue = 2.2;

vec3 Shader::shadePixel(const HitRecord& hitRecord)
{
    vec3 intersectPoint = hitRecord.hitPoint;
    vec3 eyeRay = hitRecord.eyeRay.vectorDirection;
    vec3 normal = hitRecord.normal;
    if (hitRecord.eyeRay.multiple == Infinity) {
        return vec3 (0,0,0);
    }
    
    
    vec3 colorRGB, L_a, L_d, L_s;
    vec3 incomingLightInverse = -normalize(intersectPoint-LightSourcePoint);
    vec3 eyeRayInverse = -normalize(eyeRay);
    
    // Ambient
    L_a = hitRecord.object->k_a;
    
    // Difuse
    float n_dot_l = dot(normal, incomingLightInverse);
    L_d = hitRecord.object->k_d * LightIllumination * std::max(0.0f, n_dot_l);
    
    // Blinn-Phong Specular
    vec3 v = eyeRayInverse;
    vec3 l = incomingLightInverse;
    vec3 h = normalize(v+l);
    float normal_dot_h = dot(normal, h);
    L_s = hitRecord.object->k_s * LightIllumination * pow(std::max(0.0f, normal_dot_h),SpecularPower);
    
    colorRGB = L_a + L_d + L_s;
    return colorRGB;
}


//vec3 Shader::shadePixel(const vec3& intersectPoint, const vec3& normal, const vec3& eyeRay)
//{
//    vec3 colorRGB, L_a, L_d, L_s;
//    vec3 incomingLightInverse = -normalize(intersectPoint-LightSourcePoint);
//    vec3 eyeRayInverse = -normalize(eyeRay);
//    
//    // Ambient
//    L_a = k_a;
//    
//    // Difuse
//    float n_dot_l = dot(normal, incomingLightInverse);
//    L_d = k_d * LightIllumination * std::max(0.0f, n_dot_l);
//    
//    // Blinn-Phong Specular
//    vec3 v = eyeRayInverse;
//    vec3 l = incomingLightInverse;
//    vec3 h = normalize(v+l);<commit_msg>Truly working copy!!!!<commit_after>//
//  Shader.cpp
//  COMP575_HW01
//
//  Created by <NAME> on 9/18/14.
//  Copyright (c) 2014 Gold<NAME>. All rights reserved.
//

#include "Shader.h"

float SpecularPower;
float GammaValue = 2.2;

vec3 Shader::shadePixel(const HitRecord& hitRecord)
{
    vec3 eyeRay = hitRecord.eyeRay.vectorDirection;
    vec3 eyeRayInverse = -normalize(eyeRay);
    vec3 normal = normalize(hitRecord.normal);
    vec3 intersectPoint = hitRecord.hitPoint;
    vec3 incomingLightInverse = -normalize(intersectPoint-LightSourcePoint);
    if (hitRecord.eyeRay.multiple == Infinity) {
        return vec3 (0,0,0);
    }
    
    
    vec3 colorRGB, L_a, L_d, L_s;
    
    // Ambient
    L_a = hitRecord.object->k_a;
    
    // Difuse
    float n_dot_l = dot(normal, incomingLightInverse);
    L_d = hitRecord.object->k_d * LightIllumination * std::max(0.0f, n_dot_l);
    
    // Blinn-Phong Specular
    vec3 v = eyeRayInverse;
    vec3 l = incomingLightInverse;
    vec3 h = normalize(v+l);
    float normal_dot_h = dot(normal, h);
    L_s = hitRecord.object->k_s * LightIllumination * pow(std::max(0.0f, normal_dot_h),hitRecord.object->SpecularPower);
    
    colorRGB = L_a + L_d + L_s;
    return colorRGB;
}


//vec3 Shader::shadePixel(const vec3& intersectPoint, const vec3& normal, const vec3& eyeRay)
//{
//    vec3 colorRGB, L_a, L_d, L_s;
//    vec3 incomingLightInverse = -normalize(intersectPoint-LightSourcePoint);
//    vec3 eyeRayInverse = -normalize(eyeRay);
//    
//    // Ambient
//    L_a = k_a;
//    
//    // Difuse
//    float n_dot_l = dot(normal, incomingLightInverse);
//    L_d = k_d * LightIllumination * std::max(0.0f, n_dot_l);
//    
//    // Blinn-Phong Specular
//    vec3 v = eyeRayInverse;
//    vec3 l = incomingLightInverse;
//    vec3 h = normalize(v+l);
{'fraction_non_alphanumeric': 0.13557906458797328, 'fraction_numerical': 0.025612472160356347, 'mean_word_length': 2.8101802757158008, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 14, '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': '4475748', 'n_tokens_mistral': 1399, 'n_tokens_neox': 1352, 'n_words': 273}