phong_fragment_shader 光照模型
Eigen::Vector3f light_dir = light.position – point;
Eigen::Vector3f view_dir = eye_pos – point;
float r = light_dir.dot(light_dir);
// ambient
Eigen::Vector3f La = ka.cwiseProduct(amb_light_intensity);
// diffuse
Eigen::Vector3f Ld = kd.cwiseProduct(light.intensity / r);
Ld *= std::max(0.0f, normal.normalized().dot(light_dir.normalized()));
Eigen::Vector3f h = (light_dir + view_dir).normalized();
Eigen::Vector3f Ls = ks.cwiseProduct(light.intensity / r);
Ls *= std::pow(std::max(0.0f, normal.normalized().dot(h)), p);
result_color += (La + Ld + Ls);
有个问题:结果变成了黑白小牛,从光栅化的角度来讲。
This post has received 1 vote down.
Attachments:
You must be
logged in to view attached files.