本文整理汇总了C++中ShadingPoint::get_distance方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadingPoint::get_distance方法的具体用法?C++ ShadingPoint::get_distance怎么用?C++ ShadingPoint::get_distance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadingPoint
的用法示例。
在下文中一共展示了ShadingPoint::get_distance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: apply_aerial_perspective
void apply_aerial_perspective(
const InputValues& values,
const ShadingContext& shading_context,
const PixelContext& pixel_context,
const ShadingPoint& shading_point,
ShadingResult& shading_result) const
{
Spectrum sky_color;
if (m_aerial_persp_mode == AerialPerspSkyColor)
sky_color = values.m_aerial_persp_sky_color;
else
{
// Retrieve the environment shader of the scene.
const Scene& scene = shading_point.get_scene();
const EnvironmentShader* environment_shader =
scene.get_environment()->get_environment_shader();
if (environment_shader)
{
// Execute the environment shader to obtain the sky color in the direction of the ray.
InputEvaluator input_evaluator(shading_context.get_texture_cache());
const ShadingRay& ray = shading_point.get_ray();
const Vector3d direction = normalize(ray.m_dir);
ShadingResult sky;
environment_shader->evaluate(
shading_context,
pixel_context,
input_evaluator,
direction,
sky);
sky_color = sky.m_main.m_color;
}
else sky_color.set(0.0f);
}
// Compute the blend factor.
const double d = shading_point.get_distance() * m_aerial_persp_rcp_distance;
const double k = m_aerial_persp_intensity * exp(d);
const double blend = min(k, 1.0);
// Blend the shading result and the sky color.
sky_color *= static_cast<float>(blend);
shading_result.m_main.m_color *= static_cast<float>(1.0 - blend);
shading_result.m_main.m_color += sky_color;
}
示例2: evaluate
//.........这里部分代码省略.........
shading_point.get_shading_basis().get_tangent_v();
shading_result.set_main_to_linear_rgb(vector3_to_color(v));
}
break;
case GeometricNormal:
shading_result.set_main_to_linear_rgb(
vector3_to_color(shading_point.get_geometric_normal()));
break;
case OriginalShadingNormal:
shading_result.set_main_to_linear_rgb(
vector3_to_color(shading_point.get_original_shading_normal()));
break;
case WorldSpacePosition:
{
const Vector3d& p = shading_point.get_point();
shading_result.set_main_to_linear_rgb(
Color3f(Color3d(p.x, p.y, p.z)));
}
break;
case Sides:
shading_result.set_main_to_linear_rgb(
shading_point.get_side() == ObjectInstance::FrontSide
? Color3f(0.0f, 0.0f, 1.0f)
: Color3f(1.0f, 0.0f, 0.0f));
break;
case Depth:
shading_result.set_main_to_linear_rgb(
Color3f(static_cast<float>(shading_point.get_distance())));
break;
case ScreenSpaceWireframe:
{
// Initialize the shading result to the background color.
shading_result.set_main_to_linear_rgba(Color4f(0.0f, 0.0f, 0.8f, 0.5f));
if (shading_point.is_triangle_primitive())
{
// Film space thickness of the wires.
const double SquareWireThickness = square(0.00025);
// Retrieve the time, the scene and the camera.
const double time = shading_point.get_time().m_absolute;
const Scene& scene = shading_point.get_scene();
const Camera& camera = *scene.get_camera();
// Compute the film space coordinates of the intersection point.
Vector2d point_ndc;
camera.project_point(time, shading_point.get_point(), point_ndc);
// Loop over the triangle edges.
for (size_t i = 0; i < 3; ++i)
{
// Retrieve the end points of this edge.
const size_t j = (i + 1) % 3;
const Vector3d vi = shading_point.get_vertex(i);
const Vector3d vj = shading_point.get_vertex(j);
// Compute the film space coordinates of the edge's end points.
Vector2d vi_ndc, vj_ndc;
if (!camera.project_segment(time, vi, vj, vi_ndc, vj_ndc))