diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp index cb7fbc7af2..5e8c284d82 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_createscene.cpp @@ -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 ); } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp index 1cad056fbc..835899508d 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/c3d_render_raytracing.cpp @@ -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(); diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.cpp b/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.cpp index 0223344f2d..51a044883d 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.cpp +++ b/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.cpp @@ -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; } diff --git a/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.h b/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.h index aac1ef971b..c74299e9de 100644 --- a/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.h +++ b/3d-viewer/3d_rendering/3d_render_raytracing/cmaterial.h @@ -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; };