3D-Viewer: Limit the recursive reflection level

Fixes https://gitlab.com/kicad/code/kicad/issues/5426
This commit is contained in:
Mario Luzeiro 2020-08-30 19:46:40 +01:00 committed by Jon Evans
parent 820e3089a2
commit 2feef44fca
4 changed files with 7 additions and 1 deletions

View File

@ -188,6 +188,7 @@ void C3D_RENDER_RAYTRACING::setupMaterials()
0.0f, // transparency
0.50f ); // reflection
m_materials.m_Floor.SetCastShadows( false );
m_materials.m_Floor.SetReflectionsRecursiveLevel( 1 );
}

View File

@ -1805,7 +1805,8 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor,
if( !aIsInsideObject &&
(objMaterial->GetReflection() > 0.0f) &&
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) )
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) &&
( aRecursiveLevel < objMaterial->GetReflectionsRecursiveLevel() ) )
{
const unsigned int reflection_number_of_samples = objMaterial->GetNrReflectionsSamples();

View File

@ -80,6 +80,7 @@ CMATERIAL::CMATERIAL( const SFVEC3F &aAmbient,
m_cast_shadows = true;
m_refraction_nr_samples = 4;
m_reflections_nr_samples = 3;
m_reflections_recursive_levels = 2;
m_normal_perturbator = NULL;
}

View File

@ -215,10 +215,12 @@ public:
float GetAbsorvance() const { return m_absorbance; }
unsigned int GetNrRefractionsSamples() const { return m_refraction_nr_samples; }
unsigned int GetNrReflectionsSamples() const { return m_reflections_nr_samples; }
unsigned int GetReflectionsRecursiveLevel() const { return m_reflections_recursive_levels; }
void SetAbsorvance( float aAbsorvanceFactor ) { m_absorbance = aAbsorvanceFactor; }
void SetNrRefractionsSamples( unsigned int aNrRefractions ) { m_refraction_nr_samples = aNrRefractions; }
void SetNrReflectionsSamples( unsigned int aNrReflections ) { m_reflections_nr_samples = aNrReflections; }
void SetReflectionsRecursiveLevel( unsigned int aReflectionsLevel ) { m_reflections_recursive_levels = aReflectionsLevel; }
/**
* @brief SetCastShadows - Set if the material can receive shadows
@ -268,6 +270,7 @@ protected:
bool m_cast_shadows; ///< true if this object will block the light
unsigned int m_refraction_nr_samples; ///< nr of rays that will be interpolated for this material if it is a transparent
unsigned int m_reflections_nr_samples; ///< nr of rays that will be interpolated for this material if it is reflective
unsigned int m_reflections_recursive_levels; ///< nr of levels it allows for reflection recursiveness
const CPROCEDURALGENERATOR *m_normal_perturbator;
};