本文整理汇总了C++中Ray::getColorContribution方法的典型用法代码示例。如果您正苦于以下问题:C++ Ray::getColorContribution方法的具体用法?C++ Ray::getColorContribution怎么用?C++ Ray::getColorContribution使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ray
的用法示例。
在下文中一共展示了Ray::getColorContribution方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mix
/**
* The fresnel rayTrace function creates a fresnel effect for the objects it affects.
*/
glm::vec3 rayTrace(Ray &ray, const float& t, const glm::vec3& normal, RayTracerState& state) {
glm::vec3 n = glm::normalize(normal);
glm::vec3 v = glm::normalize(ray.getDirection());
if(glm::dot(n, v) < 0.0f){
glm::vec3 refl_dir = reflect(n, v);
glm::vec3 refract_dir = refract(n, v, eta_in);
float fresnel = RF0_in + (1.0f-RF0_in)*glm::pow((1.0f-glm::dot(-v, n)), 5.0f);
float reflect_contribution = ray.getColorContribution()*fresnel;
float refract_contribution = ray.getColorContribution()*(1.0f-fresnel);
glm::vec3 reflect = state.rayTrace(ray.spawn(t, refl_dir, reflect_contribution));
glm::vec3 refract = state.rayTrace(ray.spawn(t, refract_dir, refract_contribution));
return glm::mix(refract, reflect, fresnel);
}
else {
glm::vec3 refl_dir(glm::reflect(v, n));
glm::vec3 refract_dir = refract(-n, v, eta_out);
float fresnel = RF0_out + (1.0f-RF0_out)*glm::pow((1.0f-glm::dot(refract_dir, n)), 5.0f);
float reflect_contribution = ray.getColorContribution()*fresnel;
float refract_contribution = ray.getColorContribution()*(1.0f-fresnel);
glm::vec3 reflect = state.rayTrace(ray.spawn(t, refl_dir, reflect_contribution));
glm::vec3 refract = state.rayTrace(ray.spawn(t, refract_dir, refract_contribution));
return glm::mix(refract, reflect, fresnel);
}
}
示例2: rayTrace
glm::vec3 rayTrace(Ray &ray, const float& t, const glm::vec3& normal, RayTracerState& state) {
return state.rayTrace(ray.spawn(t, glm::reflect(ray.getDirection(), normal), ray.getColorContribution() - absorb_amount));
}