本文整理汇总了C++中ShadingPoint::get_geometric_normal方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadingPoint::get_geometric_normal方法的具体用法?C++ ShadingPoint::get_geometric_normal怎么用?C++ ShadingPoint::get_geometric_normal使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadingPoint
的用法示例。
在下文中一共展示了ShadingPoint::get_geometric_normal方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
DirectLightingIntegrator::DirectLightingIntegrator(
const ShadingContext& shading_context,
const LightSampler& light_sampler,
const ShadingPoint& shading_point,
const Vector3d& outgoing,
const BSDF& bsdf,
const void* bsdf_data,
const int bsdf_sampling_modes,
const int light_sampling_modes,
const size_t bsdf_sample_count,
const size_t light_sample_count,
const bool indirect)
: m_shading_context(shading_context)
, m_light_sampler(light_sampler)
, m_shading_point(shading_point)
, m_point(shading_point.get_point())
, m_geometric_normal(shading_point.get_geometric_normal())
, m_shading_basis(shading_point.get_shading_basis())
, m_time(shading_point.get_time())
, m_outgoing(outgoing)
, m_bsdf(bsdf)
, m_bsdf_data(bsdf_data)
, m_bsdf_sampling_modes(bsdf_sampling_modes)
, m_light_sampling_modes(light_sampling_modes)
, m_bsdf_sample_count(bsdf_sample_count)
, m_light_sample_count(light_sample_count)
, m_indirect(indirect)
{
assert(is_normalized(outgoing));
}
示例2: compute_ibl_environment_sampling
void compute_ibl_environment_sampling(
SamplingContext& sampling_context,
const ShadingContext& shading_context,
const EnvironmentEDF& environment_edf,
const ShadingPoint& shading_point,
const Vector3d& outgoing,
const BSDF& bsdf,
const void* bsdf_data,
const int env_sampling_modes,
const size_t bsdf_sample_count,
const size_t env_sample_count,
Spectrum& radiance)
{
assert(is_normalized(outgoing));
const Vector3d& geometric_normal = shading_point.get_geometric_normal();
const Basis3d& shading_basis = shading_point.get_shading_basis();
radiance.set(0.0f);
// todo: if we had a way to know that a BSDF is purely specular, we could
// immediately return black here since there will be no contribution from
// such a BSDF.
sampling_context.split_in_place(2, env_sample_count);
for (size_t i = 0; i < env_sample_count; ++i)
{
// Generate a uniform sample in [0,1)^2.
const Vector2d s = sampling_context.next_vector2<2>();
// Sample the environment.
InputEvaluator input_evaluator(shading_context.get_texture_cache());
Vector3d incoming;
Spectrum env_value;
double env_prob;
environment_edf.sample(
input_evaluator,
s,
incoming,
env_value,
env_prob);
// Cull samples behind the shading surface.
assert(is_normalized(incoming));
const double cos_in = dot(incoming, shading_basis.get_normal());
if (cos_in < 0.0)
continue;
// Discard occluded samples.
const double transmission =
shading_context.get_tracer().trace(
shading_point,
incoming,
ShadingRay::ShadowRay);
if (transmission == 0.0)
continue;
// Evaluate the BSDF.
Spectrum bsdf_value;
const double bsdf_prob =
bsdf.evaluate(
bsdf_data,
false, // not adjoint
true, // multiply by |cos(incoming, normal)|
geometric_normal,
shading_basis,
outgoing,
incoming,
env_sampling_modes,
bsdf_value);
if (bsdf_prob == 0.0)
continue;
// Compute MIS weight.
const double mis_weight =
mis_power2(
env_sample_count * env_prob,
bsdf_sample_count * bsdf_prob);
// Add the contribution of this sample to the illumination.
env_value *= static_cast<float>(transmission / env_prob * mis_weight);
env_value *= bsdf_value;
radiance += env_value;
}
if (env_sample_count > 1)
radiance /= static_cast<float>(env_sample_count);
}
示例3: compute_ibl_bsdf_sampling
void compute_ibl_bsdf_sampling(
SamplingContext& sampling_context,
const ShadingContext& shading_context,
const EnvironmentEDF& environment_edf,
const ShadingPoint& shading_point,
const Vector3d& outgoing,
const BSDF& bsdf,
const void* bsdf_data,
const int bsdf_sampling_modes,
const size_t bsdf_sample_count,
const size_t env_sample_count,
Spectrum& radiance)
{
assert(is_normalized(outgoing));
const Vector3d& geometric_normal = shading_point.get_geometric_normal();
const Basis3d& shading_basis = shading_point.get_shading_basis();
radiance.set(0.0f);
for (size_t i = 0; i < bsdf_sample_count; ++i)
{
// Sample the BSDF.
// todo: rendering will be incorrect if the BSDF value returned by the sample() method
// includes the contribution of a specular component since these are explicitly rejected
// afterward. We need a mechanism to indicate that we want the contribution of some of
// the components only.
Vector3d incoming;
Spectrum bsdf_value;
double bsdf_prob;
const BSDF::Mode bsdf_mode =
bsdf.sample(
sampling_context,
bsdf_data,
false, // not adjoint
true, // multiply by |cos(incoming, normal)|
geometric_normal,
shading_basis,
outgoing,
incoming,
bsdf_value,
bsdf_prob);
// Filter scattering modes.
if (!(bsdf_sampling_modes & bsdf_mode))
return;
// Discard occluded samples.
const double transmission =
shading_context.get_tracer().trace(
shading_point,
incoming,
ShadingRay::ShadowRay);
if (transmission == 0.0)
continue;
// Evaluate the environment's EDF.
InputEvaluator input_evaluator(shading_context.get_texture_cache());
Spectrum env_value;
double env_prob;
environment_edf.evaluate(
input_evaluator,
incoming,
env_value,
env_prob);
// Apply all weights, including MIS weight.
if (bsdf_mode == BSDF::Specular)
env_value *= static_cast<float>(transmission);
else
{
const double mis_weight =
mis_power2(
bsdf_sample_count * bsdf_prob,
env_sample_count * env_prob);
env_value *= static_cast<float>(transmission / bsdf_prob * mis_weight);
}
// Add the contribution of this sample to the illumination.
env_value *= bsdf_value;
radiance += env_value;
}
if (bsdf_sample_count > 1)
radiance /= static_cast<float>(bsdf_sample_count);
}
示例4: evaluate
void DiagnosticSurfaceShader::evaluate(
SamplingContext& sampling_context,
const PixelContext& pixel_context,
const ShadingContext& shading_context,
const ShadingPoint& shading_point,
ShadingResult& shading_result) const
{
switch (m_shading_mode)
{
case Color:
{
shading_result.set_main_to_opaque_pink_linear_rgba();
const Material* material = shading_point.get_material();
if (material)
{
const Material::RenderData& material_data = material->get_render_data();
#ifdef APPLESEED_WITH_OSL
// Execute the OSL shader if there is one.
if (material_data.m_shader_group)
{
shading_context.execute_osl_shading(
*material_data.m_shader_group,
shading_point);
}
#endif
if (material_data.m_bsdf)
{
InputEvaluator input_evaluator(shading_context.get_texture_cache());
material_data.m_bsdf->evaluate_inputs(
shading_context,
input_evaluator,
shading_point);
const Vector3d direction = -normalize(shading_point.get_ray().m_dir);
material_data.m_bsdf->evaluate(
input_evaluator.data(),
false,
false,
shading_point.get_geometric_normal(),
shading_point.get_shading_basis(),
direction,
direction,
ScatteringMode::All,
shading_result.m_main.m_color);
shading_result.m_color_space = ColorSpaceSpectral;
}
}
}
break;
case Coverage:
shading_result.set_main_to_linear_rgb(Color3f(1.0f));
break;
case Barycentric:
shading_result.set_main_to_linear_rgb(
vector2_to_color(shading_point.get_bary()));
break;
case UV:
shading_result.set_main_to_linear_rgb(
uvs_to_color(shading_point.get_uv(0)));
break;
case Tangent:
case Bitangent:
case ShadingNormal:
{
#ifdef APPLESEED_WITH_OSL
const Material* material = shading_point.get_material();
if (material)
{
const Material::RenderData& material_data = material->get_render_data();
// Execute the OSL shader if there is one.
if (material_data.m_shader_group)
{
sampling_context.split_in_place(2, 1);
shading_context.execute_osl_bump(
*material_data.m_shader_group,
shading_point,
sampling_context.next_vector2<2>());
}
}
#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:
//.........这里部分代码省略.........