mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-20 11:26:11 +00:00
Eliminated a bug in sdf shader. New parameters added to the user interface.
This commit is contained in:
parent
30ef0f281d
commit
ed6e7292e9
@ -57,8 +57,17 @@ void SdfGpuPlugin::initParameterSet(MeshDocument&, RichParameterSet& par)
|
||||
par.addParam(new RichInt("peelingIteration", 2, "Peeling Iteration",
|
||||
"Number of depth peeling iteration"));
|
||||
|
||||
par.addParam(new RichFloat("peelingTolerance", 0.0005f, "Peeling Tolerance",
|
||||
par.addParam(new RichFloat("peelingTolerance", 0.00005f, "Peeling Tolerance",
|
||||
"We will throw away the set of ray distances for each cone which distance " ));
|
||||
|
||||
par.addParam(new RichFloat("depthTolerance", 0.0001f, "Depth tolerance",
|
||||
"A small delta that is the minimal distance in depth between two vertex" ));
|
||||
|
||||
par.addParam(new RichFloat("minCos", 0.7f, "Min cosine",
|
||||
"Min accepteded cosine of the angle between rays and vertex normals" ));
|
||||
|
||||
par.addParam(new RichFloat("maxCos", 1.0f, "Max cosine",
|
||||
"Max accepteded cosine of the angle between rays and vertex normals" ));
|
||||
}
|
||||
|
||||
|
||||
@ -73,6 +82,9 @@ bool SdfGpuPlugin::applyFilter(MeshDocument& md, RichParameterSet& pars, vcg::Ca
|
||||
int peel = pars.getInt("peelingIteration");
|
||||
mTolerance = pars.getFloat("peelingTolerance");
|
||||
mPeelingTextureSize = pars.getInt("DepthTextureSize");
|
||||
mDepthTolerance = pars.getFloat("depthTolerance");
|
||||
mMinCos = pars.getFloat("minCos");
|
||||
mMaxCos = pars.getFloat("maxCos");
|
||||
assert( onPrimitive==ON_VERTICES && "Face mode not supported yet" );
|
||||
|
||||
//******* GL & MESH INIT **********/
|
||||
@ -385,6 +397,12 @@ void SdfGpuPlugin::calculateSdfHW(FramebufferObject& fboFront, FramebufferObject
|
||||
// Set viewport Size
|
||||
mSDFProgram->setUniform1f("viewpSize", mResTextureDim );
|
||||
|
||||
mSDFProgram->setUniform1f("depthTolerance", mDepthTolerance);
|
||||
|
||||
// mSDFProgram->setUniform1f("minCos", 0.7);
|
||||
|
||||
// mSDFProgram->setUniform1f("maxCos", 1.0);
|
||||
|
||||
|
||||
// Screen-aligned Quad
|
||||
glBegin(GL_QUADS);
|
||||
@ -435,12 +453,11 @@ void SdfGpuPlugin::TraceRays(int peelingIteration, float tolerance, const Point3
|
||||
mFboA->bind();
|
||||
setCamera(dir, mm->cm.bbox);
|
||||
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f, 1.0f);
|
||||
|
||||
/* glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(10.0,2.5);*/
|
||||
fillFrameBuffer(i%2==0, mm);
|
||||
mFboA->unbind();
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
//glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
if(i%2)
|
||||
calculateSdfHW(*mFboB,*mFboA,dir);
|
||||
|
||||
@ -56,6 +56,9 @@ protected:
|
||||
FloatTexture2D* mDepthTextureB;
|
||||
unsigned int mPeelingTextureSize;
|
||||
float mTolerance;
|
||||
float mDepthTolerance;
|
||||
float mMinCos;
|
||||
float mMaxCos;
|
||||
GPUProgram* mDeepthPeelingProgram;
|
||||
GPUProgram* mSDFProgram;
|
||||
};
|
||||
|
||||
@ -31,6 +31,9 @@ uniform vec3 viewDirection;
|
||||
uniform mat4 mvprMatrix;
|
||||
uniform float viewpSize;
|
||||
uniform float texSize;
|
||||
uniform float depthTolerance;
|
||||
uniform float minCos;
|
||||
uniform float maxCos;
|
||||
|
||||
vec4 project(vec4 coords)
|
||||
{
|
||||
@ -59,7 +62,7 @@ void main(void)
|
||||
float cosAngle = max(0.0,dot(N.xyz, viewDirection));
|
||||
|
||||
|
||||
if ( zFront >= P.z && cosAngle >= 0.6 && cosAngle <= 1.0)
|
||||
if ( (zFront-depthTolerance) <= P.z && P.z <= (zFront+depthTolerance) && cosAngle >= 0.7 && cosAngle <= 1.0)
|
||||
{
|
||||
|
||||
sdf = max(0.0,(zBack-zFront) * cosAngle) ;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user