本文整理汇总了C++中Hit::get_s方法的典型用法代码示例。如果您正苦于以下问题:C++ Hit::get_s方法的具体用法?C++ Hit::get_s怎么用?C++ Hit::get_s使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Hit
的用法示例。
在下文中一共展示了Hit::get_s方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TraceRay
// does the recursive (shadow rays & recursive/glossy rays) work
Vec3f RayTracer::TraceRay(const Ray &ray, Hit &hit, int bounce_count) const
{
hit = Hit();
bool intersect = CastRay(ray,hit,false);
Vec3f answer(args->background_color_linear);
if (intersect == true) {
const Material *m = hit.getMaterial();
assert (m != NULL);
// rays coming from the light source are set to white, don't bother to ray trace further.
if (m->getEmittedColor().Length() > 0.001) {
answer = Vec3f(1,1,1);
} else {
// ambient light
answer = args->ambient_light_linear *
m->getDiffuseColor(hit.get_s(),hit.get_t());
// Shadows
answer += shadows(ray, hit);
// Reflections
Vec3f reflectiveColor = m->getReflectiveColor();
double roughness = m->getRoughness();
if (bounce_count > 0 && reflectiveColor.Length() > MIN_COLOR_LEN) {
answer += reflectiveColor * reflections(ray, hit, bounce_count, roughness);
}
}
}
return answer;
}
示例2: Shade
Vec3f Material::Shade(const Ray &ray, const Hit &hit,
const Vec3f &dirToLight,
const Vec3f &lightColor, ArgParser *args) const {
Vec3f point = ray.pointAtParameter(hit.getT());
Vec3f n = hit.getNormal();
Vec3f e = ray.getDirection()*-1.0f;
Vec3f l = dirToLight;
Vec3f answer = Vec3f(0,0,0);
// emitted component
// -----------------
answer += getEmittedColor();
// diffuse component
// -----------------
double dot_nl = n.Dot3(l);
if (dot_nl < 0) dot_nl = 0;
answer += lightColor * getDiffuseColor(hit.get_s(),hit.get_t()) * dot_nl;
// specular component (Phong)
// ------------------
// make up reasonable values for other Phong parameters
Vec3f specularColor = reflectiveColor;
double exponent = 100;
// compute ideal reflection angle
Vec3f r = (l*-1.0f) + n * (2 * dot_nl);
r.Normalize();
double dot_er = e.Dot3(r);
if (dot_er < 0) dot_er = 0;
answer += lightColor*specularColor*pow(dot_er,exponent)* dot_nl;
return answer;
}
示例3: getEmittedColor
glm::vec3 Material::Shade(const Ray &ray, const Hit &hit,
const glm::vec3 &dirToLight,
const glm::vec3 &lightColor, ArgParser *args) const {
glm::vec3 point = ray.pointAtParameter(hit.getT());
glm::vec3 n = hit.getNormal();
glm::vec3 e = ray.getDirection()*-1.0f;
glm::vec3 l = dirToLight;
glm::vec3 answer = glm::vec3(0,0,0);
// emitted component
// -----------------
answer += getEmittedColor();
// diffuse component
// -----------------
float dot_nl = glm::dot(n,l);
if (dot_nl < 0) dot_nl = 0;
answer += lightColor * getDiffuseColor(hit.get_s(),hit.get_t()) * dot_nl;
// specular component (Phong)
// ------------------
// make up reasonable values for other Phong parameters
glm::vec3 specularColor = reflectiveColor;
float exponent = 100;
// compute ideal reflection angle
glm::vec3 r = (l*-1.0f) + n * (2 * dot_nl);
r = glm::normalize(r);
float dot_er = glm::dot(e,r);
if (dot_er < 0) dot_er = 0;
answer += lightColor*specularColor*float(pow(dot_er,exponent))* dot_nl;
return answer;
}