本文整理汇总了C++中ShadingPoint::get_side方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadingPoint::get_side方法的具体用法?C++ ShadingPoint::get_side怎么用?C++ ShadingPoint::get_side使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadingPoint
的用法示例。
在下文中一共展示了ShadingPoint::get_side方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute_ibl_bssrdf_sampling
void compute_ibl_bssrdf_sampling(
SamplingContext& sampling_context,
const ShadingContext& shading_context,
const EnvironmentEDF& environment_edf,
const BSSRDF& bssrdf,
const void* bssrdf_data,
const ShadingPoint& incoming_point,
const ShadingPoint& outgoing_point,
const Dual3d& outgoing,
const size_t bssrdf_sample_count,
const size_t env_sample_count,
Spectrum& radiance)
{
assert(is_normalized(outgoing.get_value()));
radiance.set(0.0f);
sampling_context.split_in_place(2, bssrdf_sample_count);
for (size_t i = 0; i < bssrdf_sample_count; ++i)
{
// Generate a uniform sample in [0,1)^2.
const Vector2d s = sampling_context.next_vector2<2>();
// Sample the BSSRDF (hemisphere cosine).
Vector3d incoming = sample_hemisphere_cosine(s);
const double cos_in = incoming.y;
const double bssrdf_prob = cos_in * RcpPi;
incoming = incoming_point.get_shading_basis().transform_to_parent(incoming);
if (incoming_point.get_side() == ObjectInstance::BackSide)
incoming = -incoming;
assert(is_normalized(incoming));
// Discard occluded samples.
const double transmission =
shading_context.get_tracer().trace(
incoming_point,
incoming,
VisibilityFlags::ShadowRay);
if (transmission == 0.0)
continue;
// Evaluate the BSSRDF.
Spectrum bssrdf_value;
bssrdf.evaluate(
bssrdf_data,
outgoing_point,
outgoing.get_value(),
incoming_point,
incoming,
bssrdf_value);
// Evaluate the environment's EDF.
InputEvaluator input_evaluator(shading_context.get_texture_cache());
Spectrum env_value;
double env_prob;
environment_edf.evaluate(
shading_context,
input_evaluator,
incoming,
env_value,
env_prob);
// Compute MIS weight.
const double mis_weight =
mis_power2(
bssrdf_sample_count * bssrdf_prob,
env_sample_count * env_prob);
// Add the contribution of this sample to the illumination.
env_value *= static_cast<float>(transmission * cos_in / bssrdf_prob * mis_weight);
env_value *= bssrdf_value;
radiance += env_value;
}
if (bssrdf_sample_count > 1)
radiance /= static_cast<float>(bssrdf_sample_count);
}
示例2: evaluate
//.........这里部分代码省略.........
}
}
#endif
const Vector3d v =
m_shading_mode == ShadingNormal ? shading_point.get_shading_basis().get_normal() :
m_shading_mode == Tangent ? shading_point.get_shading_basis().get_tangent_u() :
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.