本文整理汇总了C++中ShadingPoint::get_object方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadingPoint::get_object方法的具体用法?C++ ShadingPoint::get_object怎么用?C++ ShadingPoint::get_object使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadingPoint
的用法示例。
在下文中一共展示了ShadingPoint::get_object方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
}