void OSLShaderGroupExec::execute_transparency( const ShaderGroup& shader_group, const ShadingPoint& shading_point, Alpha& alpha) const { do_execute( shader_group, shading_point, VisibilityFlags::TransparencyRay); process_transparency_tree(shading_point.get_osl_shader_globals().Ci, alpha); }
void OSLShaderGroupExec::execute_shading( const ShaderGroup& shader_group, const ShadingPoint& shading_point) const { assert(m_osl_shading_context); assert(m_osl_thread_info); m_osl_shading_system.execute( *m_osl_shading_context, *shader_group.shadergroup_ref(), shading_point.get_osl_shader_globals()); }
void OSLShaderGroupExec::execute_transparency( const ShaderGroup& shader_group, const ShadingPoint& shading_point, Alpha& alpha, float* holdout) const { // Switch temporary the ray type to Shadow. ShadingRay::TypeType saved_type = shading_point.m_ray.m_type; shading_point.m_ray.m_type = ShadingRay::ShadowRay; m_osl_shading_system.execute( *m_osl_shading_context, *shader_group.shadergroup_ref(), shading_point.get_osl_shader_globals()); process_transparency_tree(shading_point.get_osl_shader_globals().Ci, alpha); if (holdout) *holdout = process_holdout_tree(shading_point.get_osl_shader_globals().Ci); // Restore the original ray type. shading_point.m_ray.m_type = saved_type; }
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))); }
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()); }
void OSLShaderGroupExec::execute_bump( const ShaderGroup& shader_group, const ShadingPoint& shading_point, const Vector2f& s) const { // Choose between BSSRDF and BSDF. if (shader_group.has_subsurface() && s[0] < 0.5f) { do_execute( shader_group, shading_point, VisibilityFlags::SubsurfaceRay); CompositeSubsurfaceClosure c( Basis3f(shading_point.get_shading_basis()), shading_point.get_osl_shader_globals().Ci, m_arena); // Pick a shading basis from one of the BSSRDF closures. if (c.get_closure_count() > 0) { const size_t index = c.choose_closure(s[1]); shading_point.set_shading_basis( Basis3d(c.get_closure_shading_basis(index))); } } else { do_execute( shader_group, shading_point, VisibilityFlags::CameraRay); choose_bsdf_closure_shading_basis(shading_point, s); } }