added alpha masking for image weighting (still to be tested), commented out some problematic QWarning

This commit is contained in:
Marco Callieri mcallieri 2012-01-16 18:06:27 +00:00
parent cd1e37a11f
commit 8db8e30cb0
5 changed files with 38 additions and 2 deletions

View File

@ -64,7 +64,7 @@ bool TexturePainter::init( int texSize )
.AttachAndLink( fpg, &logs ) )
{
qWarning( (std::string(__func__)+": "+logs).c_str() );
// qWarning( (std::string(__func__)+": "+logs).c_str() );
return false;
}

View File

@ -370,7 +370,7 @@ bool VisibilityCheck_ShadowMap::initShaders()
!fpg.CompileSrcFile( basename+"visibility_detection.frag", &logs ) ||
!m_VisDetectionShader.Attach( vpg ).AttachAndLink( fpg, &logs ) )
{
qWarning( ( std::string(__func__)+ ": "+logs).c_str() );
// qWarning( ( std::string(__func__)+ ": "+logs).c_str() );
return false;
}

View File

@ -99,5 +99,34 @@ float VisibleSet::getWeight( const RasterModel *rm, CFaceO &f )
std::abs(2.0f*cam.Y()/rm->shot.Intrinsics.ViewportPx.Y()-1.0f) );
}
if( (m_WeightMask & W_IMG_ALPHA) && weight>0.0f )
{
vcg::Point2f ppoint0 = rm->shot.Project( f.V(0)->P() );
vcg::Point2f ppoint1 = rm->shot.Project( f.V(0)->P() );
vcg::Point2f ppoint2 = rm->shot.Project( f.V(0)->P() );
float aweight = 1.0;
float wt;
QRgb pcolor;
// vertex 0
pcolor = rm->currentPlane->image.pixel(ppoint0[0],rm->shot.Intrinsics.ViewportPx[1] - ppoint0[1]);
wt = (qAlpha(pcolor) / 255.0);
if(aweight > wt)
aweight = wt;
// vertex 0
pcolor = rm->currentPlane->image.pixel(ppoint1[0],rm->shot.Intrinsics.ViewportPx[1] - ppoint1[1]);
wt = (qAlpha(pcolor) / 255.0);
if(aweight > wt)
aweight = wt;
// vertex 0
pcolor = rm->currentPlane->image.pixel(ppoint2[0],rm->shot.Intrinsics.ViewportPx[1] - ppoint2[1]);
wt = (qAlpha(pcolor) / 255.0);
if(aweight > wt)
aweight = wt;
weight *= aweight;
}
return weight;
}

View File

@ -38,6 +38,7 @@ public:
W_ORIENTATION = 0x01,
W_DISTANCE = 0x02,
W_IMG_BORDER = 0x04,
W_IMG_ALPHA = 0x08,
};

View File

@ -147,6 +147,10 @@ void FilterImgPatchParamPlugin::initParameterSet( QAction *act,
true,
"Use image border weight",
"Includes a weight accounting for the distance to the image border during the computation of reference images") );
par.addParam(new RichBool ( "useAlphaWeight",
false,
"use image alpha weight",
"If true, alpha channel of the image is used as additional weight. In this way it is possible to mask-out parts of the images that should not be projected on the mesh. Please note this is not a transparency effect, but just influences the weigthing between different images"));
par.addParam( new RichBool( "cleanIsolatedTriangles",
true,
"Clean isolated triangles",
@ -832,6 +836,8 @@ void FilterImgPatchParamPlugin::patchBasedTextureParameterization( RasterPatchMa
weightMask |= VisibleSet::W_DISTANCE;
if( par.getBool("useImgBorderWeight") )
weightMask |= VisibleSet::W_IMG_BORDER;
if( par.getBool("useAlphaWeight") )
weightMask |= VisibleSet::W_IMG_ALPHA;
VisibleSet *faceVis = new VisibleSet( mesh, rasterList, weightMask );
Log( "VISIBILITY CHECK: %.3f sec.", 0.001f*t.elapsed() );