3D-Viewer: use the correct opacity meaning in the color settings

This commit is contained in:
Mario Luzeiro 2020-08-30 17:47:30 +01:00 committed by Jon Evans
parent 7c9bb9ab07
commit 820e3089a2
5 changed files with 40 additions and 40 deletions

View File

@ -112,9 +112,9 @@ BOARD_ADAPTER::BOARD_ADAPTER() :
m_BgColorBot = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
m_BgColorTop = SFVEC4F( 0.8, 0.8, 0.9, 1.0 );
m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 1.0 );
m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.17 );
m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.17 );
m_BoardBodyColor = SFVEC4F( 0.4, 0.4, 0.5, 0.9 );
m_SolderMaskColorTop = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
m_SolderMaskColorBot = SFVEC4F( 0.1, 0.2, 0.1, 0.83 );
m_SolderPasteColor = SFVEC4F( 0.4, 0.4, 0.4, 1.0 );
m_SilkScreenColorTop = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );
m_SilkScreenColorBot = SFVEC4F( 0.9, 0.9, 0.9, 1.0 );

View File

@ -325,7 +325,7 @@ void C3D_RENDER_OGL_LEGACY::set_layer_material( PCB_LAYER_ID aLayerID )
const SFVEC4F layerColor = get_layer_color( aLayerID );
m_materials.m_SolderMask.m_Diffuse = layerColor;
m_materials.m_SolderMask.m_Transparency = layerColor.a;
m_materials.m_SolderMask.m_Transparency = 1.0f - layerColor.a; // Convert Opacity to Transparency
if( m_boardAdapter.GetFlag( FL_USE_REALISTIC_MODE ) )
{
@ -506,7 +506,7 @@ void C3D_RENDER_OGL_LEGACY::render_board_body( bool aSkipRenderHoles )
m_materials.m_EpoxyBoard.m_Diffuse = m_boardAdapter.m_BoardBodyColor;
m_materials.m_EpoxyBoard.m_Transparency = m_boardAdapter.m_BoardBodyColor.a;
m_materials.m_EpoxyBoard.m_Transparency = 1.0f - m_boardAdapter.m_BoardBodyColor.a; // opacity to transparency
OGL_SetMaterial( m_materials.m_EpoxyBoard, 1.0f );
@ -690,7 +690,7 @@ bool C3D_RENDER_OGL_LEGACY::Redraw(
// Do not show inner layers when it is displaying the board
// and board body is full opaque
if( m_boardAdapter.GetFlag( FL_SHOW_BOARD_BODY ) &&
( m_boardAdapter.m_BoardBodyColor.a < 0.01f ) )
( m_boardAdapter.m_BoardBodyColor.a > 0.99f ) )
{
if( (layer_id > F_Cu) && (layer_id < B_Cu) )
continue;

View File

@ -51,17 +51,17 @@
/**
* @brief TransparencyAlphaControl
* Perform an interpolation step to easy control the transparency based on the
* gray color value and alpha
* gray color value and transparency
* @param aGrayColorValue - diffuse gray value
* @param aAlpha - control
* @param aTransparency - control
* @return transparency to use in material
*/
static float TransparencyAlphaControl( float aGrayColorValue, float aAlpha )
static float TransparencyControl( float aGrayColorValue, float aTransparency )
{
const float aaa = aAlpha * aAlpha * aAlpha;
const float aaa = aTransparency * aTransparency * aTransparency;
// 1.00-1.05*(1.0-x)^3
float ca = 1.0f - aAlpha;
float ca = 1.0f - aTransparency;
ca = 1.00f - 1.05f * ca * ca * ca;
return glm::max( glm::min( aGrayColorValue * ca + aaa, 1.0f ), 0.0f );
@ -137,8 +137,8 @@ void C3D_RENDER_RAYTRACING::setupMaterials()
+ m_boardAdapter.m_SolderMaskColorTop.b )
/ 3.0f;
const float solderMask_transparency = TransparencyAlphaControl( solderMask_gray,
m_boardAdapter.m_SolderMaskColorTop.a );
const float solderMask_transparency = TransparencyControl( solderMask_gray,
1.0f - m_boardAdapter.m_SolderMaskColorTop.a ); // opacity to transparency
m_materials.m_SolderMask = CBLINN_PHONG_MATERIAL(
ConvertSRGBToLinear( (SFVEC3F) m_boardAdapter.m_SolderMaskColorTop ) * 0.10f, // ambient
@ -168,7 +168,7 @@ void C3D_RENDER_RAYTRACING::setupMaterials()
8.0f / 255.0f,
10.0f / 255.0f ) ), // specular
0.1f * 128.0f, // shiness
m_boardAdapter.m_BoardBodyColor.a, // transparency
1.0f - m_boardAdapter.m_BoardBodyColor.a, // opacity to transparency
0.0f ); // reflection
m_materials.m_EpoxyBoard.SetAbsorvance( 10.0f );

View File

@ -844,7 +844,7 @@ bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC4F &aColor, const wxString& aTitle,
KIGFX::COLOR4D aDefaultColor )
{
KIGFX::COLOR4D newcolor;
KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, 1.0 - aColor.a );
KIGFX::COLOR4D oldcolor( aColor.r,aColor.g, aColor.b, aColor.a );
DIALOG_COLOR_PICKER picker( this, oldcolor, aAllowOpacityControl, aPredefinedColors, aDefaultColor );
@ -859,7 +859,7 @@ bool EDA_3D_VIEWER::Set3DColorFromUser( SFVEC4F &aColor, const wxString& aTitle,
aColor.r = newcolor.r;
aColor.g = newcolor.g;
aColor.b = newcolor.b;
aColor.a = 1.0 - newcolor.a;
aColor.a = newcolor.a;
return true;
}
@ -887,20 +887,20 @@ bool EDA_3D_VIEWER::Set3DSolderMaskColorFromUser()
{
CUSTOM_COLORS_LIST colors;
colors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, 1.0 - 0.17, "Green" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, 1.0 - 0.17, "Light Green" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0, 1.0 - 0.17, "Saturated Green" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, 1.0 - 0.17, "Red" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0, 1.0 - 0.17, "Red Light Orange" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, 1.0 - 0.17, "Red 2" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, 1.0 - 0.17, "Blue" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, 1.0 - 0.17, "Light blue 1" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, 1.0 - 0.17, "Light blue 2" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0, 1.0 - 0.17, "Green blue (dark)" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, 1.0 - 0.17, "Black" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, 1.0 - 0.17, "White" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, 1.0 - 0.17, "Purple" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, 1.0 - 0.17, "Purple Dark" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 20/255.0, 51/255.0, 36/255.0, 0.83, "Green" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 91/255.0, 168/255.0, 12/255.0, 0.83, "Light Green" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 13/255.0, 104/255.0, 11/255.0, 0.83, "Saturated Green" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 181/255.0, 19/255.0, 21/255.0, 0.83, "Red" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 239/255.0, 53/255.0, 41/255.0, 0.83, "Red Light Orange" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 210/255.0, 40/255.0, 14/255.0, 0.83, "Red 2" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 2/255.0, 59/255.0, 162/255.0, 0.83, "Blue" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 54/255.0, 79/255.0, 116/255.0, 0.83, "Light blue 1" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 61/255.0, 85/255.0, 130/255.0, 0.83, "Light blue 2" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 21/255.0, 70/255.0, 80/255.0, 0.83, "Green blue (dark)" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 11/255.0, 11/255.0, 11/255.0, 0.83, "Black" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 245/255.0, 245/255.0, 245/255.0, 0.83, "White" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 119/255.0, 31/255.0, 91/255.0, 0.83, "Purple" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 32/255.0, 2/255.0, 53/255.0, 0.83, "Purple Dark" ) );
if( Set3DColorFromUser( m_boardAdapter.m_SolderMaskColorTop, _( "Solder Mask Color" ), &colors, true, colors[0].m_Color ) )
{
@ -941,14 +941,14 @@ bool EDA_3D_VIEWER::Set3DBoardBodyColorFromUser()
{
CUSTOM_COLORS_LIST colors;
colors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0, 1.0 - 0.1, "FR4 natural, dark" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, 1.0 - 0.1, "FR4 natural" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, 1.0 - 0.1, "brown/red" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 1.0 - 0.1, "brown 1" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, 1.0 - 0.1, "brown 2" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 1.0 - 0.1, "brown 3" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, 1.0 - 0.1, "green 1" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, 1.0 - 0.1, "green 2" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 51/255.0, 43/255.0, 22/255.0, 0.9, "FR4 natural, dark" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 109/255.0, 116/255.0, 75/255.0, 0.9, "FR4 natural" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 78/255.0, 14/255.0, 5/255.0, 0.9, "brown/red" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 0.9, "brown 1" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 160/255.0, 123/255.0, 54/255.0, 0.9, "brown 2" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 146/255.0, 99/255.0, 47/255.0, 0.9, "brown 3" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 63/255.0, 126/255.0, 71/255.0, 0.9, "green 1" ) );
colors.push_back( CUSTOM_COLOR_ITEM( 117/255.0, 122/255.0, 90/255.0, 0.9, "green 2" ) );
if( Set3DColorFromUser( m_boardAdapter.m_BoardBodyColor, _( "Board Body Color" ), &colors, true, colors[0].m_Color ) )
{

View File

@ -201,11 +201,11 @@ COLOR_SETTINGS::COLOR_SETTINGS( wxString aFilename ) :
// Colors for 3D viewer, which are used as defaults unless overridden by the board
CLR( "3d_viewer.background_bottom", LAYER_3D_BACKGROUND_BOTTOM, COLOR4D( 0.4, 0.4, 0.5, 1.0 ) );
CLR( "3d_viewer.background_top", LAYER_3D_BACKGROUND_TOP, COLOR4D( 0.8, 0.8, 0.9, 1.0 ) );
CLR( "3d_viewer.board", LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 0.1 ) );
CLR( "3d_viewer.board", LAYER_3D_BOARD, COLOR4D( 0.2, 0.17, 0.09, 0.9 ) );
CLR( "3d_viewer.copper", LAYER_3D_COPPER, COLOR4D( 0.7, 0.61, 0.0, 1.0 ) );
CLR( "3d_viewer.silkscreen_bottom", LAYER_3D_SILKSCREEN_BOTTOM, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) );
CLR( "3d_viewer.silkscreen_top", LAYER_3D_SILKSCREEN_TOP, COLOR4D( 0.9, 0.9, 0.9, 1.0 ) );
CLR( "3d_viewer.soldermask", LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 0.17 ) );
CLR( "3d_viewer.soldermask", LAYER_3D_SOLDERMASK, COLOR4D( 0.08, 0.2, 0.14, 0.83 ) );
CLR( "3d_viewer.solderpaste", LAYER_3D_SOLDERPASTE, COLOR4D( 0.5, 0.5, 0.5, 1.0 ) );
}