3D-Viewer: Parameterize sampling options

This commit is contained in:
Mario Luzeiro 2020-09-04 15:12:01 +00:00 committed by Seth Hillbrand
parent ec576b5dfa
commit 306a8f57f7
12 changed files with 1323 additions and 308 deletions

View File

@ -655,6 +655,18 @@ public:
std::vector<SFVEC3F> m_raytrace_lightColor; std::vector<SFVEC3F> m_raytrace_lightColor;
std::vector<SFVEC2F> m_raytrace_lightSphericalCoords; std::vector<SFVEC2F> m_raytrace_lightSphericalCoords;
// Raytracing options
int m_raytrace_nrsamples_shadows;
int m_raytrace_nrsamples_reflections;
int m_raytrace_nrsamples_refractions;
float m_raytrace_spread_shadows;
float m_raytrace_spread_reflections;
float m_raytrace_spread_refractions;
int m_raytrace_recursivelevel_reflections;
int m_raytrace_recursivelevel_refractions;
private: private:
BOARD* m_board; BOARD* m_board;

View File

@ -74,6 +74,12 @@ static float TransparencyControl( float aGrayColorValue, float aTransparency )
void C3D_RENDER_RAYTRACING::setupMaterials() void C3D_RENDER_RAYTRACING::setupMaterials()
{ {
CMATERIAL::SetDefaultNrRefractionsSamples( m_boardAdapter.m_raytrace_nrsamples_refractions );
CMATERIAL::SetDefaultNrReflectionsSamples( m_boardAdapter.m_raytrace_nrsamples_reflections );
CMATERIAL::SetDefaultRefractionsLevel( m_boardAdapter.m_raytrace_recursivelevel_refractions );
CMATERIAL::SetDefaultReflectionsLevel( m_boardAdapter.m_raytrace_recursivelevel_reflections );
double mmTo3Dunits = IU_PER_MM * m_boardAdapter.BiuTo3Dunits(); double mmTo3Dunits = IU_PER_MM * m_boardAdapter.BiuTo3Dunits();
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
@ -154,7 +160,6 @@ void C3D_RENDER_RAYTRACING::setupMaterials()
m_materials.m_SolderMask.SetCastShadows( true ); m_materials.m_SolderMask.SetCastShadows( true );
m_materials.m_SolderMask.SetNrRefractionsSamples( 1 ); m_materials.m_SolderMask.SetNrRefractionsSamples( 1 );
m_materials.m_SolderMask.SetNrReflectionsSamples( 2 );
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_SolderMask.SetNormalPerturbator( &m_solder_mask_normal_perturbator ); m_materials.m_SolderMask.SetNormalPerturbator( &m_solder_mask_normal_perturbator );
@ -172,7 +177,6 @@ void C3D_RENDER_RAYTRACING::setupMaterials()
0.0f ); // reflection 0.0f ); // reflection
m_materials.m_EpoxyBoard.SetAbsorvance( 10.0f ); m_materials.m_EpoxyBoard.SetAbsorvance( 10.0f );
m_materials.m_EpoxyBoard.SetNrRefractionsSamples( 3 );
if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ) if( m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) )
m_materials.m_EpoxyBoard.SetNormalPerturbator( &m_board_normal_perturbator ); m_materials.m_EpoxyBoard.SetNormalPerturbator( &m_board_normal_perturbator );

View File

@ -1663,7 +1663,7 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor,
SFVEC3F outColor = objMaterial->GetEmissiveColor() + objMaterial->GetAmbientColor(); SFVEC3F outColor = objMaterial->GetEmissiveColor() + objMaterial->GetAmbientColor();
if( aRecursiveLevel > 5 ) if( aRecursiveLevel > 7 )
return outColor; return outColor;
SFVEC3F hitPoint = aHitInfo.m_HitPoint; SFVEC3F hitPoint = aHitInfo.m_HitPoint;
@ -1718,14 +1718,8 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor,
{ {
nr_lights_that_can_cast_shadows++; nr_lights_that_can_cast_shadows++;
#if USE_EXPERIMENTAL_SOFT_SHADOWS #if USE_EXPERIMENTAL_SOFT_SHADOWS
if( (!is_aa_enabled) || // For rays that are recursive, just calculate one hit shadow
if( aRecursiveLevel > 0 )
// For rays that are recursive, just calculate one hit shadow
(aRecursiveLevel > 0) ||
// Only use soft shadows if using post processing
(!m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_POST_PROCESSING ) )
)
{ {
#endif #endif
RAY rayToLight; RAY rayToLight;
@ -1743,18 +1737,26 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor,
else else
{ {
const unsigned int shadow_number_of_samples = 3; const unsigned int shadow_number_of_samples = m_boardAdapter.m_raytrace_nrsamples_shadows;
const float shadow_inc_factor = 1.0f / (float)(shadow_number_of_samples); const float shadow_inc_factor = 1.0f / (float)(shadow_number_of_samples);
for( unsigned int i = 0; i < shadow_number_of_samples; ++i ) for( unsigned int i = 0; i < shadow_number_of_samples; ++i )
{ {
const SFVEC3F unifVector = UniformRandomHemisphereDirection();
const SFVEC3F disturbed_vector_to_light = glm::normalize( vectorToLight +
unifVector *
0.05f );
RAY rayToLight; RAY rayToLight;
rayToLight.Init( hitPoint, disturbed_vector_to_light );
if( i == 0 )
{
rayToLight.Init( hitPoint, vectorToLight );
}
else
{
const SFVEC3F unifVector = UniformRandomHemisphereDirection();
const SFVEC3F disturbed_vector_to_light = glm::normalize( vectorToLight +
unifVector *
m_boardAdapter.m_raytrace_spread_shadows );
rayToLight.Init( hitPoint, disturbed_vector_to_light );
}
// !TODO: there are multiple ways that this tests can be // !TODO: there are multiple ways that this tests can be
// optimized. Eg: by packing rays or to test against the // optimized. Eg: by packing rays or to test against the
@ -1803,8 +1805,7 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor,
// Reflections // Reflections
// ///////////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////////
if( !aIsInsideObject && if( ( objMaterial->GetReflection() > 0.0f ) &&
(objMaterial->GetReflection() > 0.0f) &&
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) && m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFLECTIONS ) &&
( aRecursiveLevel < objMaterial->GetReflectionsRecursiveLevel() ) ) ( aRecursiveLevel < objMaterial->GetReflectionsRecursiveLevel() ) )
{ {
@ -1818,14 +1819,22 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor,
for( unsigned int i = 0; i < reflection_number_of_samples; ++i ) for( unsigned int i = 0; i < reflection_number_of_samples; ++i )
{ {
// Apply some randomize to the reflected vector
const SFVEC3F random_reflectVector =
glm::normalize( reflectVector +
UniformRandomHemisphereDirection() *
0.025f );
RAY reflectedRay; RAY reflectedRay;
reflectedRay.Init( hitPoint, random_reflectVector );
if( i == 0 )
{
reflectedRay.Init( hitPoint, reflectVector );
}
else
{
// Apply some randomize to the reflected vector
const SFVEC3F random_reflectVector =
glm::normalize( reflectVector +
UniformRandomHemisphereDirection() *
m_boardAdapter.m_raytrace_spread_reflections );
reflectedRay.Init( hitPoint, random_reflectVector );
}
HITINFO reflectedHit; HITINFO reflectedHit;
reflectedHit.m_tHit = std::numeric_limits<float>::infinity(); reflectedHit.m_tHit = std::numeric_limits<float>::infinity();
@ -1856,7 +1865,8 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor,
const float objTransparency = aHitInfo.pHitObject->GetModelTransparency(); const float objTransparency = aHitInfo.pHitObject->GetModelTransparency();
if( ( objTransparency > 0.0f ) && if( ( objTransparency > 0.0f ) &&
m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) ) m_boardAdapter.GetFlag( FL_RENDER_RAYTRACING_REFRACTIONS ) &&
( aRecursiveLevel < objMaterial->GetRefractionsRecursiveLevel() ) )
{ {
const float airIndex = 1.000293f; const float airIndex = 1.000293f;
const float glassIndex = 1.49f; const float glassIndex = 1.49f;
@ -1884,20 +1894,19 @@ SFVEC3F C3D_RENDER_RAYTRACING::shadeHit( const SFVEC3F &aBgColor,
{ {
RAY refractedRay; RAY refractedRay;
if( refractions_number_of_samples > 1 ) if( i == 0 )
{
refractedRay.Init( startPoint, refractedVector );
}
else
{ {
// apply some randomize to the refracted vector // apply some randomize to the refracted vector
const SFVEC3F randomizeRefractedVector = glm::normalize( refractedVector + const SFVEC3F randomizeRefractedVector = glm::normalize( refractedVector +
UniformRandomHemisphereDirection() * UniformRandomHemisphereDirection() *
0.15f * m_boardAdapter.m_raytrace_spread_refractions );
(1.0f - objTransparency) );
refractedRay.Init( startPoint, randomizeRefractedVector ); refractedRay.Init( startPoint, randomizeRefractedVector );
} }
else
{
refractedRay.Init( startPoint, refractedVector );
}
HITINFO refractedHit; HITINFO refractedHit;
refractedHit.m_tHit = std::numeric_limits<float>::infinity(); refractedHit.m_tHit = std::numeric_limits<float>::infinity();

View File

@ -31,6 +31,11 @@
#include <3d_math.h> #include <3d_math.h>
#include <wx/debug.h> #include <wx/debug.h>
int CMATERIAL::m_default_nrsamples_refractions = 4;
int CMATERIAL::m_default_nrsamples_reflections = 3;
int CMATERIAL::m_default_refractions_recursive_levels = 2;
int CMATERIAL::m_default_reflections_recursive_levels = 3;
// This may be a good value if based on nr of lights // This may be a good value if based on nr of lights
// that contribute to the illumination of that point // that contribute to the illumination of that point
#define AMBIENT_FACTOR (1.0f / 6.0f) #define AMBIENT_FACTOR (1.0f / 6.0f)
@ -46,8 +51,10 @@ CMATERIAL::CMATERIAL()
m_cast_shadows = true; m_cast_shadows = true;
m_reflection = 0.0f; m_reflection = 0.0f;
m_absorbance = 1.0f; m_absorbance = 1.0f;
m_refraction_nr_samples = 4; m_refraction_nr_samples = m_default_nrsamples_refractions;
m_reflections_nr_samples = 3; m_reflections_nr_samples = m_default_nrsamples_reflections;
m_refractions_recursive_levels = m_default_refractions_recursive_levels;
m_reflections_recursive_levels = m_default_reflections_recursive_levels;
m_normal_perturbator = NULL; m_normal_perturbator = NULL;
} }
@ -78,9 +85,10 @@ CMATERIAL::CMATERIAL( const SFVEC3F &aAmbient,
m_absorbance = 1.0f; m_absorbance = 1.0f;
m_reflection = aReflection; m_reflection = aReflection;
m_cast_shadows = true; m_cast_shadows = true;
m_refraction_nr_samples = 4; m_refraction_nr_samples = m_default_nrsamples_refractions;
m_reflections_nr_samples = 3; m_reflections_nr_samples = m_default_nrsamples_reflections;
m_reflections_recursive_levels = 2; m_refractions_recursive_levels = m_default_refractions_recursive_levels;
m_reflections_recursive_levels = m_default_reflections_recursive_levels;
m_normal_perturbator = NULL; m_normal_perturbator = NULL;
} }

View File

@ -191,9 +191,23 @@ private:
float m_scale; float m_scale;
}; };
/// A base material class that can be used to derive a material implementation /// A base material class that can be used to derive a material implementation
class CMATERIAL class CMATERIAL
{ {
public:
static void SetDefaultNrRefractionsSamples( unsigned int aNrRefractions ) { m_default_nrsamples_refractions = aNrRefractions; }
static void SetDefaultNrReflectionsSamples( unsigned int aNrReflections ) { m_default_nrsamples_reflections = aNrReflections; }
static void SetDefaultRefractionsLevel( unsigned int aRefractionLevel ) { m_default_refractions_recursive_levels = aRefractionLevel; }
static void SetDefaultReflectionsLevel( unsigned int aReflectionLevel ) { m_default_reflections_recursive_levels = aReflectionLevel; }
private:
static int m_default_nrsamples_refractions;
static int m_default_nrsamples_reflections;
static int m_default_refractions_recursive_levels;
static int m_default_reflections_recursive_levels;
public: public:
CMATERIAL(); CMATERIAL();
CMATERIAL( const SFVEC3F &aAmbient, CMATERIAL( const SFVEC3F &aAmbient,
@ -216,11 +230,13 @@ public:
unsigned int GetNrRefractionsSamples() const { return m_refraction_nr_samples; } unsigned int GetNrRefractionsSamples() const { return m_refraction_nr_samples; }
unsigned int GetNrReflectionsSamples() const { return m_reflections_nr_samples; } unsigned int GetNrReflectionsSamples() const { return m_reflections_nr_samples; }
unsigned int GetReflectionsRecursiveLevel() const { return m_reflections_recursive_levels; } unsigned int GetReflectionsRecursiveLevel() const { return m_reflections_recursive_levels; }
unsigned int GetRefractionsRecursiveLevel() const { return m_refractions_recursive_levels; }
void SetAbsorvance( float aAbsorvanceFactor ) { m_absorbance = aAbsorvanceFactor; } void SetAbsorvance( float aAbsorvanceFactor ) { m_absorbance = aAbsorvanceFactor; }
void SetNrRefractionsSamples( unsigned int aNrRefractions ) { m_refraction_nr_samples = aNrRefractions; } void SetNrRefractionsSamples( unsigned int aNrRefractions ) { m_refraction_nr_samples = aNrRefractions; }
void SetNrReflectionsSamples( unsigned int aNrReflections ) { m_reflections_nr_samples = aNrReflections; } void SetNrReflectionsSamples( unsigned int aNrReflections ) { m_reflections_nr_samples = aNrReflections; }
void SetReflectionsRecursiveLevel( unsigned int aReflectionsLevel ) { m_reflections_recursive_levels = aReflectionsLevel; } void SetReflectionsRecursiveLevel( unsigned int aReflectionsLevel ) { m_reflections_recursive_levels = aReflectionsLevel; }
void SetRefractionsRecursiveLevel( unsigned int aRefractionsLevel ) { m_refractions_recursive_levels = aRefractionsLevel; }
/** /**
* @brief SetCastShadows - Set if the material can receive shadows * @brief SetCastShadows - Set if the material can receive shadows
@ -270,6 +286,7 @@ protected:
bool m_cast_shadows; ///< true if this object will block the light 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_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_nr_samples; ///< nr of rays that will be interpolated for this material if it is reflective
unsigned int m_refractions_recursive_levels; ///< nr of levels it allows for refractions recursiveness
unsigned int m_reflections_recursive_levels; ///< nr of levels it allows for reflection recursiveness unsigned int m_reflections_recursive_levels; ///< nr of levels it allows for reflection recursiveness
const CPROCEDURALGENERATOR *m_normal_perturbator; const CPROCEDURALGENERATOR *m_normal_perturbator;

View File

@ -88,6 +88,25 @@ EDA_3D_VIEWER_SETTINGS::EDA_3D_VIEWER_SETTINGS()
m_params.emplace_back( new PARAM<bool>( "render.raytrace_shadows", m_params.emplace_back( new PARAM<bool>( "render.raytrace_shadows",
&m_Render.raytrace_shadows, true ) ); &m_Render.raytrace_shadows, true ) );
m_params.emplace_back( new PARAM<int>( "render.raytrace_nrsamples_shadows",
&m_Render.raytrace_nrsamples_shadows, 3 ) );
m_params.emplace_back( new PARAM<int>( "render.raytrace_nrsamples_reflections",
&m_Render.raytrace_nrsamples_reflections, 3 ) );
m_params.emplace_back( new PARAM<int>( "render.raytrace_nrsamples_refractions",
&m_Render.raytrace_nrsamples_refractions, 4 ) );
m_params.emplace_back( new PARAM<int>( "render.raytrace_recursivelevel_reflections",
&m_Render.raytrace_recursivelevel_reflections, 3 ) );
m_params.emplace_back( new PARAM<int>( "render.raytrace_recursivelevel_refractions",
&m_Render.raytrace_recursivelevel_refractions, 2 ) );
m_params.emplace_back( new PARAM<float>( "render.raytrace_spread_shadows",
&m_Render.raytrace_spread_shadows, 0.05f ) );
m_params.emplace_back( new PARAM<float>( "render.raytrace_spread_reflections",
&m_Render.raytrace_spread_reflections, 0.025f ) );
m_params.emplace_back( new PARAM<float>( "render.raytrace_spread_refractions",
&m_Render.raytrace_spread_refractions, 0.025f ) );
m_params.emplace_back( new PARAM<COLOR4D>( "render.raytrace_lightColorCamera", m_params.emplace_back( new PARAM<COLOR4D>( "render.raytrace_lightColorCamera",
&m_Render.raytrace_lightColorCamera, &m_Render.raytrace_lightColorCamera,
COLOR4D( 0.2, 0.2, 0.2, 1.0 ) ) ); COLOR4D( 0.2, 0.2, 0.2, 1.0 ) ) );

View File

@ -49,6 +49,17 @@ public:
bool raytrace_refractions; bool raytrace_refractions;
bool raytrace_shadows; bool raytrace_shadows;
int raytrace_nrsamples_shadows;
int raytrace_nrsamples_reflections;
int raytrace_nrsamples_refractions;
float raytrace_spread_shadows;
float raytrace_spread_reflections;
float raytrace_spread_refractions;
int raytrace_recursivelevel_reflections;
int raytrace_recursivelevel_refractions;
KIGFX::COLOR4D raytrace_lightColorCamera; KIGFX::COLOR4D raytrace_lightColorCamera;
KIGFX::COLOR4D raytrace_lightColorTop; KIGFX::COLOR4D raytrace_lightColorTop;
KIGFX::COLOR4D raytrace_lightColorBottom; KIGFX::COLOR4D raytrace_lightColorBottom;

View File

@ -217,6 +217,17 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataToWindow()
m_checkBoxRaytracing_antiAliasing->SetValue( m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) ); m_checkBoxRaytracing_antiAliasing->SetValue( m_settings.GetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING ) );
m_checkBoxRaytracing_proceduralTextures->SetValue( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) ); m_checkBoxRaytracing_proceduralTextures->SetValue( m_settings.GetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES ) );
m_spinCtrl_NrSamples_Shadows->SetValue( m_settings.m_raytrace_nrsamples_shadows );
m_spinCtrl_NrSamples_Reflections->SetValue( m_settings.m_raytrace_nrsamples_reflections );
m_spinCtrl_NrSamples_Refractions->SetValue( m_settings.m_raytrace_nrsamples_refractions );
m_spinCtrlDouble_SpreadFactor_Shadows->SetValue( m_settings.m_raytrace_spread_shadows * 100.0f );
m_spinCtrlDouble_SpreadFactor_Reflections->SetValue( m_settings.m_raytrace_spread_reflections * 100.0f );
m_spinCtrlDouble_SpreadFactor_Refractions->SetValue( m_settings.m_raytrace_spread_refractions * 100.0f );
m_spinCtrlRecursiveLevel_Reflections->SetValue( m_settings.m_raytrace_recursivelevel_reflections );
m_spinCtrlRecursiveLevel_Refractions->SetValue( m_settings.m_raytrace_recursivelevel_refractions );
TransferLightDataToWindow(); TransferLightDataToWindow();
// Camera Options // Camera Options
@ -274,6 +285,17 @@ bool DIALOG_3D_VIEW_OPTIONS::TransferDataFromWindow()
m_settings.SetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING, m_checkBoxRaytracing_antiAliasing->GetValue() ); m_settings.SetFlag( FL_RENDER_RAYTRACING_ANTI_ALIASING, m_checkBoxRaytracing_antiAliasing->GetValue() );
m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, m_checkBoxRaytracing_proceduralTextures->GetValue() ); m_settings.SetFlag( FL_RENDER_RAYTRACING_PROCEDURAL_TEXTURES, m_checkBoxRaytracing_proceduralTextures->GetValue() );
m_settings.m_raytrace_nrsamples_shadows = m_spinCtrl_NrSamples_Shadows->GetValue();
m_settings.m_raytrace_nrsamples_reflections = m_spinCtrl_NrSamples_Reflections->GetValue();
m_settings.m_raytrace_nrsamples_refractions= m_spinCtrl_NrSamples_Refractions->GetValue();
m_settings.m_raytrace_spread_shadows = static_cast<float>( m_spinCtrlDouble_SpreadFactor_Shadows->GetValue() ) / 100.0f;
m_settings.m_raytrace_spread_reflections = static_cast<float>( m_spinCtrlDouble_SpreadFactor_Reflections->GetValue() ) / 100.0f;
m_settings.m_raytrace_spread_refractions = static_cast<float>( m_spinCtrlDouble_SpreadFactor_Refractions->GetValue() ) / 100.0f;
m_settings.m_raytrace_recursivelevel_reflections = m_spinCtrlRecursiveLevel_Reflections->GetValue();
m_settings.m_raytrace_recursivelevel_refractions = m_spinCtrlRecursiveLevel_Refractions->GetValue();
auto Transfer_color = [] ( SFVEC3F& aTarget, wxColourPickerCtrl *aSource ) auto Transfer_color = [] ( SFVEC3F& aTarget, wxColourPickerCtrl *aSource )
{ {
const wxColour color = aSource->GetColour(); const wxColour color = aSource->GetColour();

View File

@ -404,18 +404,11 @@ DIALOG_3D_VIEW_OPTIONS_BASE::DIALOG_3D_VIEW_OPTIONS_BASE( wxWindow* parent, wxWi
sbSizerRaytracingRenderOptions->SetMinSize( wxSize( -1,32 ) ); sbSizerRaytracingRenderOptions->SetMinSize( wxSize( -1,32 ) );
wxFlexGridSizer* fgSizer9; wxFlexGridSizer* fgSizer9;
fgSizer9 = new wxFlexGridSizer( 4, 4, 0, 0 ); fgSizer9 = new wxFlexGridSizer( 2, 4, 0, 0 );
fgSizer9->SetFlexibleDirection( wxBOTH ); fgSizer9->SetFlexibleDirection( wxBOTH );
fgSizer9->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE ); fgSizer9->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_NONE );
fgSizer9->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
m_checkBoxRaytracing_renderShadows = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Shadows"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_renderShadows->SetValue(true);
fgSizer9->Add( m_checkBoxRaytracing_renderShadows, 0, wxALL, 5 );
fgSizer9->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 ); fgSizer9->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
m_checkBoxRaytracing_proceduralTextures = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Procedural textures"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkBoxRaytracing_proceduralTextures = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Procedural textures"), wxDefaultPosition, wxDefaultSize, 0 );
@ -430,20 +423,6 @@ DIALOG_3D_VIEW_OPTIONS_BASE::DIALOG_3D_VIEW_OPTIONS_BASE( wxWindow* parent, wxWi
fgSizer9->Add( m_checkBoxRaytracing_addFloor, 0, wxALL, 5 ); fgSizer9->Add( m_checkBoxRaytracing_addFloor, 0, wxALL, 5 );
fgSizer9->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
m_checkBoxRaytracing_showRefractions = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Refractions"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_showRefractions->SetValue(true);
fgSizer9->Add( m_checkBoxRaytracing_showRefractions, 0, wxALL, 5 );
fgSizer9->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
m_checkBoxRaytracing_showReflections = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Reflections"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_showReflections->SetValue(true);
fgSizer9->Add( m_checkBoxRaytracing_showReflections, 0, wxALL, 5 );
fgSizer9->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 ); fgSizer9->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
m_checkBoxRaytracing_antiAliasing = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Anti-aliasing"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkBoxRaytracing_antiAliasing = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Anti-aliasing"), wxDefaultPosition, wxDefaultSize, 0 );
@ -458,7 +437,106 @@ DIALOG_3D_VIEW_OPTIONS_BASE::DIALOG_3D_VIEW_OPTIONS_BASE( wxWindow* parent, wxWi
fgSizer9->Add( m_checkBoxRaytracing_postProcessing, 0, wxALL, 5 ); fgSizer9->Add( m_checkBoxRaytracing_postProcessing, 0, wxALL, 5 );
sbSizerRaytracingRenderOptions->Add( fgSizer9, 1, wxALL, 5 ); sbSizerRaytracingRenderOptions->Add( fgSizer9, 0, wxALL, 5 );
m_staticline4 = new wxStaticLine( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
sbSizerRaytracingRenderOptions->Add( m_staticline4, 0, wxEXPAND | wxALL, 5 );
wxFlexGridSizer* fgSizer111;
fgSizer111 = new wxFlexGridSizer( 0, 5, 0, 0 );
fgSizer111->SetFlexibleDirection( wxBOTH );
fgSizer111->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );
fgSizer111->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
fgSizer111->Add( 0, 0, 1, wxEXPAND, 5 );
m_staticText19 = new wxStaticText( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Number of Samples"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText19->Wrap( -1 );
fgSizer111->Add( m_staticText19, 0, wxALL, 5 );
m_staticText201 = new wxStaticText( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Spread Factor %"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText201->Wrap( -1 );
fgSizer111->Add( m_staticText201, 0, wxALL, 5 );
m_staticText211 = new wxStaticText( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Recursive Level"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticText211->Wrap( -1 );
fgSizer111->Add( m_staticText211, 0, wxALL, 5 );
fgSizer111->Add( 0, 0, 1, wxEXPAND, 5 );
m_checkBoxRaytracing_renderShadows = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Shadows"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_renderShadows->SetValue(true);
fgSizer111->Add( m_checkBoxRaytracing_renderShadows, 0, wxALL, 5 );
m_spinCtrl_NrSamples_Shadows = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 64, 0 );
m_spinCtrl_NrSamples_Shadows->SetToolTip( _("Number of rays that will be cast, into light direction, to evaluate a shadow point") );
fgSizer111->Add( m_spinCtrl_NrSamples_Shadows, 0, wxALL, 5 );
m_spinCtrlDouble_SpreadFactor_Shadows = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 );
m_spinCtrlDouble_SpreadFactor_Shadows->SetDigits( 1 );
m_spinCtrlDouble_SpreadFactor_Shadows->SetToolTip( _("Random direction factor of the cast rays") );
fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Shadows, 0, wxALL, 5 );
fgSizer111->Add( 0, 0, 1, wxEXPAND, 5 );
fgSizer111->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
m_checkBoxRaytracing_showReflections = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Reflections"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_showReflections->SetValue(true);
fgSizer111->Add( m_checkBoxRaytracing_showReflections, 0, wxALL, 5 );
m_spinCtrl_NrSamples_Reflections = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 32, 0 );
m_spinCtrl_NrSamples_Reflections->SetToolTip( _("Number of rays that will be cast to evaluate a reflection point") );
fgSizer111->Add( m_spinCtrl_NrSamples_Reflections, 0, wxALL, 5 );
m_spinCtrlDouble_SpreadFactor_Reflections = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 );
m_spinCtrlDouble_SpreadFactor_Reflections->SetDigits( 1 );
m_spinCtrlDouble_SpreadFactor_Reflections->SetToolTip( _("Random direction factor of the cast rays") );
fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Reflections, 0, wxALL, 5 );
m_spinCtrlRecursiveLevel_Reflections = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 );
m_spinCtrlRecursiveLevel_Reflections->SetToolTip( _("Interactions number that a ray can travel through objects. (higher number of levels improve results, specially on very transparent boards)") );
fgSizer111->Add( m_spinCtrlRecursiveLevel_Reflections, 0, wxALL, 5 );
fgSizer111->Add( 0, 0, 1, wxLEFT|wxRIGHT, 5 );
m_checkBoxRaytracing_showRefractions = new wxCheckBox( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, _("Refractions"), wxDefaultPosition, wxDefaultSize, 0 );
m_checkBoxRaytracing_showRefractions->SetValue(true);
fgSizer111->Add( m_checkBoxRaytracing_showRefractions, 0, wxALL, 5 );
m_spinCtrl_NrSamples_Refractions = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 5, 0 );
m_spinCtrl_NrSamples_Refractions->SetToolTip( _("Number of rays that will be cast to evaluate a refraction point") );
fgSizer111->Add( m_spinCtrl_NrSamples_Refractions, 0, wxALL, 5 );
m_spinCtrlDouble_SpreadFactor_Refractions = new wxSpinCtrlDouble( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 0.1, 25, 0, 1 );
m_spinCtrlDouble_SpreadFactor_Refractions->SetDigits( 1 );
m_spinCtrlDouble_SpreadFactor_Refractions->SetToolTip( _("Random direction factor of the cast rays") );
fgSizer111->Add( m_spinCtrlDouble_SpreadFactor_Refractions, 0, wxALL, 5 );
m_spinCtrlRecursiveLevel_Refractions = new wxSpinCtrl( sbSizerRaytracingRenderOptions->GetStaticBox(), wxID_ANY, wxEmptyString, wxDefaultPosition, wxSize( 124,-1 ), wxSP_ARROW_KEYS, 1, 7, 0 );
m_spinCtrlRecursiveLevel_Refractions->SetToolTip( _("Number of bounces that a ray can hit reflective objects") );
fgSizer111->Add( m_spinCtrlRecursiveLevel_Refractions, 0, wxALL, 5 );
sbSizerRaytracingRenderOptions->Add( fgSizer111, 1, wxALL, 5 );
sbSizerRaytracingRenderOptions->Add( 0, 0, 1, wxEXPAND, 5 );
bSizer12->Add( sbSizerRaytracingRenderOptions, 0, wxALL|wxEXPAND, 5 ); bSizer12->Add( sbSizerRaytracingRenderOptions, 0, wxALL|wxEXPAND, 5 );
@ -470,7 +548,7 @@ DIALOG_3D_VIEW_OPTIONS_BASE::DIALOG_3D_VIEW_OPTIONS_BASE( wxWindow* parent, wxWi
m_panel4->SetSizer( bSizerRaytracing ); m_panel4->SetSizer( bSizerRaytracing );
m_panel4->Layout(); m_panel4->Layout();
bSizerRaytracing->Fit( m_panel4 ); bSizerRaytracing->Fit( m_panel4 );
m_notebook2->AddPage( m_panel4, _("Render Options"), false ); m_notebook2->AddPage( m_panel4, _("Render Options"), true );
m_panel5 = new wxPanel( m_notebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); m_panel5 = new wxPanel( m_notebook2, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL );
wxBoxSizer* bSizer17; wxBoxSizer* bSizer17;
bSizer17 = new wxBoxSizer( wxVERTICAL ); bSizer17 = new wxBoxSizer( wxVERTICAL );
@ -700,7 +778,7 @@ DIALOG_3D_VIEW_OPTIONS_BASE::DIALOG_3D_VIEW_OPTIONS_BASE( wxWindow* parent, wxWi
m_panel5->SetSizer( bSizer17 ); m_panel5->SetSizer( bSizer17 );
m_panel5->Layout(); m_panel5->Layout();
bSizer17->Fit( m_panel5 ); bSizer17->Fit( m_panel5 );
m_notebook2->AddPage( m_panel5, _("Lights configuration"), true ); m_notebook2->AddPage( m_panel5, _("Lights configuration"), false );
bSizer14->Add( m_notebook2, 1, wxEXPAND | wxALL, 5 ); bSizer14->Add( m_notebook2, 1, wxEXPAND | wxALL, 5 );

File diff suppressed because it is too large Load Diff

View File

@ -96,13 +96,25 @@ class DIALOG_3D_VIEW_OPTIONS_BASE : public DIALOG_SHIM
wxPanel* m_panelRaytracing; wxPanel* m_panelRaytracing;
wxNotebook* m_notebook2; wxNotebook* m_notebook2;
wxPanel* m_panel4; wxPanel* m_panel4;
wxCheckBox* m_checkBoxRaytracing_renderShadows;
wxCheckBox* m_checkBoxRaytracing_proceduralTextures; wxCheckBox* m_checkBoxRaytracing_proceduralTextures;
wxCheckBox* m_checkBoxRaytracing_addFloor; wxCheckBox* m_checkBoxRaytracing_addFloor;
wxCheckBox* m_checkBoxRaytracing_showRefractions;
wxCheckBox* m_checkBoxRaytracing_showReflections;
wxCheckBox* m_checkBoxRaytracing_antiAliasing; wxCheckBox* m_checkBoxRaytracing_antiAliasing;
wxCheckBox* m_checkBoxRaytracing_postProcessing; wxCheckBox* m_checkBoxRaytracing_postProcessing;
wxStaticLine* m_staticline4;
wxStaticText* m_staticText19;
wxStaticText* m_staticText201;
wxStaticText* m_staticText211;
wxCheckBox* m_checkBoxRaytracing_renderShadows;
wxSpinCtrl* m_spinCtrl_NrSamples_Shadows;
wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Shadows;
wxCheckBox* m_checkBoxRaytracing_showReflections;
wxSpinCtrl* m_spinCtrl_NrSamples_Reflections;
wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Reflections;
wxSpinCtrl* m_spinCtrlRecursiveLevel_Reflections;
wxCheckBox* m_checkBoxRaytracing_showRefractions;
wxSpinCtrl* m_spinCtrl_NrSamples_Refractions;
wxSpinCtrlDouble* m_spinCtrlDouble_SpreadFactor_Refractions;
wxSpinCtrl* m_spinCtrlRecursiveLevel_Refractions;
wxPanel* m_panel5; wxPanel* m_panel5;
wxStaticText* m_staticText17; wxStaticText* m_staticText17;
wxColourPickerCtrl* m_colourPickerCameraLight; wxColourPickerCtrl* m_colourPickerCameraLight;

View File

@ -535,6 +535,17 @@ void EDA_3D_VIEWER::LoadSettings( APP_SETTINGS_BASE *aCfg )
m_boardAdapter.GridSet( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) ); m_boardAdapter.GridSet( static_cast<GRID3D_TYPE>( cfg->m_Render.grid_type ) );
m_boardAdapter.AntiAliasingSet( static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) ); m_boardAdapter.AntiAliasingSet( static_cast<ANTIALIASING_MODE>( cfg->m_Render.opengl_AA_mode ) );
m_boardAdapter.m_raytrace_nrsamples_shadows = cfg->m_Render.raytrace_nrsamples_shadows;
m_boardAdapter.m_raytrace_nrsamples_reflections = cfg->m_Render.raytrace_nrsamples_reflections;
m_boardAdapter.m_raytrace_nrsamples_refractions = cfg->m_Render.raytrace_nrsamples_refractions;
m_boardAdapter.m_raytrace_spread_shadows = cfg->m_Render.raytrace_spread_shadows;
m_boardAdapter.m_raytrace_spread_reflections = cfg->m_Render.raytrace_spread_reflections;
m_boardAdapter.m_raytrace_spread_refractions = cfg->m_Render.raytrace_spread_refractions;
m_boardAdapter.m_raytrace_recursivelevel_refractions = cfg->m_Render.raytrace_recursivelevel_refractions;
m_boardAdapter.m_raytrace_recursivelevel_reflections = cfg->m_Render.raytrace_recursivelevel_reflections;
// When opening the 3D viewer, we use the opengl mode, not the ray tracing engine // When opening the 3D viewer, we use the opengl mode, not the ray tracing engine
// because the ray tracing is very time consumming, and can be seen as not working // because the ray tracing is very time consumming, and can be seen as not working
// (freeze window) with large boards. // (freeze window) with large boards.
@ -608,6 +619,17 @@ void EDA_3D_VIEWER::SaveSettings( APP_SETTINGS_BASE *aCfg )
cfg->m_Render.raytrace_lightAzimuth[i] = (int)( m_boardAdapter.m_raytrace_lightSphericalCoords[i].y * 180.0f ); cfg->m_Render.raytrace_lightAzimuth[i] = (int)( m_boardAdapter.m_raytrace_lightSphericalCoords[i].y * 180.0f );
} }
cfg->m_Render.raytrace_nrsamples_shadows = m_boardAdapter.m_raytrace_nrsamples_shadows;
cfg->m_Render.raytrace_nrsamples_reflections = m_boardAdapter.m_raytrace_nrsamples_reflections;
cfg->m_Render.raytrace_nrsamples_refractions = m_boardAdapter.m_raytrace_nrsamples_refractions;
cfg->m_Render.raytrace_spread_shadows = m_boardAdapter.m_raytrace_spread_shadows;
cfg->m_Render.raytrace_spread_reflections = m_boardAdapter.m_raytrace_spread_reflections;
cfg->m_Render.raytrace_spread_refractions = m_boardAdapter.m_raytrace_spread_refractions;
cfg->m_Render.raytrace_recursivelevel_refractions = m_boardAdapter.m_raytrace_recursivelevel_refractions;
cfg->m_Render.raytrace_recursivelevel_reflections = m_boardAdapter.m_raytrace_recursivelevel_reflections;
#define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag ) #define TRANSFER_SETTING( field, flag ) cfg->m_Render.field = m_boardAdapter.GetFlag( flag )
cfg->m_Render.engine = static_cast<int>( m_boardAdapter.RenderEngineGet() ); cfg->m_Render.engine = static_cast<int>( m_boardAdapter.RenderEngineGet() );