本文整理汇总了C++中ShadingPoint::get_object_instance方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadingPoint::get_object_instance方法的具体用法?C++ ShadingPoint::get_object_instance怎么用?C++ ShadingPoint::get_object_instance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadingPoint
的用法示例。
在下文中一共展示了ShadingPoint::get_object_instance方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: shade_hit_point
void ShadingEngine::shade_hit_point(
SamplingContext& sampling_context,
const PixelContext& pixel_context,
const ShadingContext& shading_context,
const ShadingPoint& shading_point,
ShadingResult& shading_result) const
{
// Retrieve the material of the intersected surface.
const Material* material = shading_point.get_material();
// Compute the alpha channel of the main output.
if (material && material->get_alpha_map())
{
// There is an alpha map: evaluate it.
material->get_alpha_map()->evaluate(
shading_context.get_texture_cache(),
shading_point.get_uv(0),
shading_result.m_main.m_alpha);
}
else
{
// No alpha map: solid sample.
shading_result.m_main.m_alpha = Alpha(1.0f);
}
#ifdef WITH_OSL
if (material && material->get_osl_surface() && material->get_osl_surface()->has_transparency())
{
Alpha a;
shading_context.execute_osl_transparency(
*material->get_osl_surface(),
shading_point,
a);
shading_result.m_main.m_alpha *= a;
}
#endif
if (shading_result.m_main.m_alpha[0] > 0.0f || material->shade_alpha_cutouts())
{
// Use the diagnostic surface shader if there is one.
const SurfaceShader* surface_shader = m_diagnostic_surface_shader.get();
if (surface_shader == 0)
{
if (material == 0)
{
// The intersected surface has no material: return solid pink.
shading_result.set_main_to_opaque_pink_linear_rgba();
shading_result.set_aovs_to_transparent_black_linear_rgba();
return;
}
// Use the surface shader of the intersected surface.
surface_shader = material->get_surface_shader();
if (surface_shader == 0)
{
// The intersected surface has no surface shader: return solid pink.
shading_result.set_main_to_opaque_pink_linear_rgba();
shading_result.set_aovs_to_transparent_black_linear_rgba();
return;
}
}
// Execute the surface shader.
surface_shader->evaluate(
sampling_context,
pixel_context,
shading_context,
shading_point,
shading_result);
// Set AOVs.
shading_result.set_entity_aov(shading_point.get_assembly());
shading_result.set_entity_aov(shading_point.get_assembly_instance());
shading_result.set_entity_aov(shading_point.get_object());
shading_result.set_entity_aov(shading_point.get_object_instance());
if (material)
shading_result.set_entity_aov(*material);
shading_result.set_entity_aov(*surface_shader);
}
else
{
// Alpha is zero: shade as transparent black.
shading_result.set_main_to_transparent_black_linear_rgba();
shading_result.set_aovs_to_transparent_black_linear_rgba();
}
}
示例2: evaluate
//.........这里部分代码省略.........
{
assert(shading_point.is_curve_primitive());
// todo: implement.
}
}
break;
case AmbientOcclusion:
{
// Compute the occlusion.
const double occlusion =
compute_ambient_occlusion(
sampling_context,
sample_hemisphere_uniform<double>,
shading_context.get_intersector(),
shading_point,
m_ao_max_distance,
m_ao_samples);
// Return a gray scale value proportional to the accessibility.
const float accessibility = static_cast<float>(1.0 - occlusion);
shading_result.set_main_to_linear_rgb(Color3f(accessibility));
}
break;
case AssemblyInstances:
shading_result.set_main_to_linear_rgb(
integer_to_color(shading_point.get_assembly_instance().get_uid()));
break;
case ObjectInstances:
shading_result.set_main_to_linear_rgb(
integer_to_color(shading_point.get_object_instance().get_uid()));
break;
case Regions:
{
const uint32 h =
mix_uint32(
static_cast<uint32>(shading_point.get_object_instance().get_uid()),
static_cast<uint32>(shading_point.get_region_index()));
shading_result.set_main_to_linear_rgb(integer_to_color(h));
}
break;
case Primitives:
{
const uint32 h =
mix_uint32(
static_cast<uint32>(shading_point.get_object_instance().get_uid()),
static_cast<uint32>(shading_point.get_region_index()),
static_cast<uint32>(shading_point.get_primitive_index()));
shading_result.set_main_to_linear_rgb(integer_to_color(h));
}
break;
case Materials:
{
const Material* material = shading_point.get_material();
if (material)
shading_result.set_main_to_linear_rgb(integer_to_color(material->get_uid()));
else shading_result.set_main_to_opaque_pink_linear_rgba();
}
break;