本文整理汇总了C++中ShadingPoint类的典型用法代码示例。如果您正苦于以下问题:C++ ShadingPoint类的具体用法?C++ ShadingPoint怎么用?C++ ShadingPoint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ShadingPoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: trace_same_material
bool Intersector::trace_same_material(
const ShadingRay& ray,
const ShadingPoint& parent_shading_point,
const bool offset_origin,
ShadingPoint& shading_point) const
{
if (do_trace_same_material(ray, parent_shading_point, offset_origin, shading_point))
{
// do_trace_same_material() intersects only with triangles
// whose normal points in the same direction as the ray.
// Triangles are intersected from the inside of the object and
// shading_point.get_shading_normal() points inside the object.
// todo: we maybe need a better way to flip the shading normal here.
const Basis3d& basis = shading_point.get_shading_basis();
shading_point.set_shading_basis(
Basis3d(
-basis.get_normal(),
-basis.get_tangent_u(),
basis.get_tangent_v()));
return true;
}
return false;
}
示例2: shade_environment
void ShadingEngine::shade_environment(
SamplingContext& sampling_context,
const ShadingContext& shading_context,
const ShadingPoint& shading_point,
ShadingResult& shading_result) const
{
// Retrieve the environment shader of the scene.
const EnvironmentShader* environment_shader =
shading_point.get_scene().get_environment()->get_environment_shader();
if (environment_shader)
{
// There is an environment shader: execute it.
InputEvaluator input_evaluator(shading_context.get_texture_cache());
const ShadingRay& ray = shading_point.get_ray();
const Vector3d direction = normalize(ray.m_dir);
environment_shader->evaluate(
input_evaluator,
direction,
shading_result);
// Set environment shader AOV.
shading_result.set_entity_aov(*environment_shader);
}
else
{
// No environment shader: shade as transparent black.
shading_result.set_main_to_transparent_black_linear_rgba();
shading_result.set_aovs_to_transparent_black_linear_rgba();
}
}
示例3: assert
bool Intersector::trace(
const ShadingRay& ray,
ShadingPoint& shading_point,
const ShadingPoint* parent_shading_point) const
{
assert(shading_point.m_scene == 0);
assert(shading_point.hit() == false);
assert(parent_shading_point == 0 || parent_shading_point != &shading_point);
assert(parent_shading_point == 0 || parent_shading_point->hit());
// Update ray casting statistics.
++m_ray_count;
// Initialize the shading point.
shading_point.m_region_kit_cache = &m_region_kit_cache;
shading_point.m_tess_cache = &m_tess_cache;
shading_point.m_scene = &m_trace_context.get_scene();
shading_point.m_ray = ray;
// Compute ray info once for the entire traversal.
const ShadingRay::RayInfoType ray_info(shading_point.m_ray);
// Refine and offset the previous intersection point.
if (parent_shading_point &&
parent_shading_point->hit() &&
!(parent_shading_point->m_members & ShadingPoint::HasRefinedPoints))
parent_shading_point->refine_and_offset();
// Retrieve assembly tree.
const AssemblyTree& assembly_tree = m_trace_context.get_assembly_tree();
// Check the intersection between the ray and the assembly tree.
AssemblyLeafVisitor visitor(
shading_point,
assembly_tree,
m_region_tree_cache,
m_triangle_tree_cache,
parent_shading_point
#ifdef FOUNDATION_BSP_ENABLE_TRAVERSAL_STATS
, m_triangle_bsp_traversal_stats
#endif
);
AssemblyLeafIntersector intersector;
intersector.intersect(
assembly_tree,
shading_point.m_ray,
ray_info,
visitor
#ifdef FOUNDATION_BVH_ENABLE_TRAVERSAL_STATS
, m_assembly_bvh_traversal_stats
#endif
);
// Detect and report self-intersections.
if (m_report_self_intersections)
report_self_intersection(shading_point, parent_shading_point);
return shading_point.hit();
}
示例4: compute_eta
float BSSRDF::compute_eta(
const ShadingPoint& shading_point,
const float ior)
{
const float outside_ior =
shading_point.is_entering()
? shading_point.get_ray().get_current_ior()
: shading_point.get_ray().get_previous_ior();
return outside_ior / ior;
}
示例5: evaluate_pdf
double LightSampler::evaluate_pdf(const ShadingPoint& shading_point) const
{
assert(shading_point.is_triangle_primitive());
const EmittingTriangleKey triangle_key(
shading_point.get_assembly_instance().get_uid(),
shading_point.get_object_instance_index(),
shading_point.get_region_index(),
shading_point.get_primitive_index());
const EmittingTriangle* triangle = m_emitting_triangle_hash_table.get(triangle_key);
return triangle->m_triangle_prob * triangle->m_rcp_area;
}
示例6: trace_back_sides
void Intersector::trace_back_sides(
ShadingRay ray,
ShadingPoint& shading_point) const
{
while (trace(ray, shading_point))
{
if (dot(ray.m_dir, shading_point.get_original_shading_normal()) > 0.0)
break;
shading_point.refine_and_offset();
ray.m_org = shading_point.get_offset_point(ray.m_dir);
shading_point.clear();
}
}
示例7: add_back_lighting
void add_back_lighting(
const InputValues& values,
SamplingContext& sampling_context,
const PixelContext& pixel_context,
const ShadingContext& shading_context,
const ShadingPoint& shading_point,
Spectrum& radiance,
SpectrumStack& aovs) const
{
const Vector3d& p = shading_point.get_point();
const Vector3d& n = shading_point.get_original_shading_normal();
const Vector3d& d = shading_point.get_ray().m_dir;
// Construct a ray perpendicular to the other side of the surface.
ShadingRay back_ray(shading_point.get_ray());
back_ray.m_tmax *= norm(d);
back_ray.m_dir = dot(d, n) > 0.0 ? -n : n;
back_ray.m_org = p - back_ray.m_tmax * back_ray.m_dir;
ShadingPoint back_shading_point(shading_point);
back_shading_point.set_ray(back_ray);
Spectrum back_radiance(0.0f);
SpectrumStack back_aovs(aovs.size(), 0.0f);
// Compute back lighting.
for (size_t i = 0; i < m_back_lighting_samples; ++i)
{
shading_context.get_lighting_engine()->compute_lighting(
sampling_context,
pixel_context,
shading_context,
back_shading_point,
back_radiance,
back_aovs);
}
// Apply translucency factor.
back_radiance *= values.m_translucency;
back_aovs *= values.m_translucency;
// Divide by the number of samples.
const float rcp_sample_count = 1.0f / static_cast<float>(m_back_lighting_samples);
back_radiance *= rcp_sample_count;
back_aovs *= rcp_sample_count;
// Add back lighting contribution.
radiance += back_radiance;
aovs += back_aovs;
}
示例8: do_compute_lighting
void do_compute_lighting(
SamplingContext& sampling_context,
const ShadingContext& shading_context,
const ShadingPoint& shading_point,
Spectrum& radiance, // output radiance, in W.sr^-1.m^-2
SpectrumStack& aovs)
{
PathVisitor path_visitor(
m_params,
m_light_sampler,
sampling_context,
shading_context,
shading_point.get_scene(),
radiance,
aovs);
PathTracer<PathVisitor, false> path_tracer( // false = not adjoint
path_visitor,
m_params.m_rr_min_path_length,
m_params.m_max_path_length,
shading_context.get_max_iterations());
const size_t path_length =
path_tracer.trace(
sampling_context,
shading_context,
shading_point);
// Update statistics.
++m_path_count;
m_path_length.insert(path_length);
}
示例9: evaluate_inputs
void BSDF::evaluate_inputs(
InputEvaluator& input_evaluator,
const ShadingPoint& shading_point,
const size_t offset) const
{
input_evaluator.evaluate(get_inputs(), shading_point.get_uv(0), offset);
}
示例10: evaluate_alpha
void Tracer::evaluate_alpha(
const Material& material,
const ShadingPoint& shading_point,
Alpha& alpha) const
{
// Init to fully opaque.
alpha.set(1.0f);
// Evaluate the alpha map at the shading point.
if (const Source* alpha_map = material.get_alpha_map())
{
alpha_map->evaluate(
m_texture_cache,
shading_point.get_uv(0),
alpha);
}
#ifdef WITH_OSL
if (const ShaderGroup* sg = material.get_osl_surface())
{
if (sg->has_transparency())
{
Alpha a;
m_shadergroup_exec.execute_transparency(
*sg,
shading_point,
a);
alpha *= a;
}
}
#endif
}
示例11: 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;
}
示例12: do_execute
void OSLShaderGroupExec::do_execute(
const ShaderGroup& shader_group,
const ShadingPoint& shading_point,
const VisibilityFlags::Type ray_flags) const
{
assert(m_osl_shading_context);
assert(m_osl_thread_info);
shading_point.initialize_osl_shader_globals(
shader_group,
ray_flags,
m_osl_shading_system.renderer());
m_osl_shading_system.execute(
m_osl_shading_context,
*reinterpret_cast<OSL::ShaderGroup*>(shader_group.osl_shader_group()),
shading_point.get_osl_shader_globals());
}
示例13: choose_bsdf_closure_shading_basis
void OSLShaderGroupExec::choose_bsdf_closure_shading_basis(
const ShadingPoint& shading_point,
const Vector2f& s) const
{
CompositeSurfaceClosure c(
Basis3f(shading_point.get_shading_basis()),
shading_point.get_osl_shader_globals().Ci,
m_arena);
float pdfs[CompositeSurfaceClosure::MaxClosureEntries];
const size_t num_closures = c.compute_pdfs(ScatteringMode::All, pdfs);
if (num_closures == 0)
return;
const size_t index = c.choose_closure(s[1], num_closures, pdfs);
shading_point.set_shading_basis(
Basis3d(c.get_closure_shading_basis(index)));
}
示例14: execute_shading
void OSLShaderGroupExec::execute_shading(
const ShaderGroup& shader_group,
const ShadingPoint& shading_point) const
{
do_execute(
shader_group,
shading_point,
shading_point.get_ray().m_flags);
}
示例15: evaluate_inputs
void BSSRDF::evaluate_inputs(
const ShadingContext& shading_context,
InputEvaluator& input_evaluator,
const ShadingPoint& shading_point,
const size_t offset) const
{
input_evaluator.evaluate(get_inputs(), shading_point.get_uv(0), offset);
prepare_inputs(input_evaluator.data() + offset);
}