Skip to content

Commit

Permalink
fixed addplight bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AjayLimaye committed Dec 10, 2013
1 parent 75a0a8b commit 86c3c0f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 65 deletions.
1 change: 1 addition & 0 deletions drishti/plugins/plugins.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = common \
mesh \
meshpaint \
itk
13 changes: 0 additions & 13 deletions drishti/shaderfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,12 +1295,6 @@ ShaderFactory::genHighQualitySliceShaderString(bool bit16,

if (tearPresent || cropPresent || pathCropPresent)
shader += " gl_FragColor.rgba = mix(gl_FragColor.rgba, vec4(0.0,0.0,0.0,0.0), feather);\n";

if (shadows && peel && peelType == 2)
{
shader += QString(" vg1.y += float(%1);\n").arg(lastSet);
shader += " gl_FragColor = mix(texture2D(lutTex, vg1.xy), gl_FragColor, peelfeather);\n";
}

if (viewPresent) shader += "blend(otexCoord, vg, gl_FragColor);\n";
if (pathViewPresent) shader += "pathblend(otexCoord, vg, gl_FragColor);\n";
Expand Down Expand Up @@ -1525,13 +1519,6 @@ ShaderFactory::genSliceShadowShaderString(bool bit16,
if (tearPresent || cropPresent || pathCropPresent)
shader += " gl_FragColor.rgba = mix(gl_FragColor.rgba, vec4(0.0,0.0,0.0,0.0), feather);\n";

if (peel && peelType==2)
{
float reduceShadow = 1.0f - qBound(0.0f, (peelMin+1.0f)*0.5f, 1.0f);
shader += QString(" gl_FragColor.rgba = mix(gl_FragColor.rgba, vec4(0.0,0.0,0.0,0.0), float(%1));\n").\
arg(reduceShadow);
}

if (viewPresent) shader += "blend(otexCoord, vg, gl_FragColor);\n";
if (pathViewPresent) shader += "pathblend(otexCoord, vg, gl_FragColor);\n";

Expand Down
30 changes: 3 additions & 27 deletions drishti/shaderfactory2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ ShaderFactory2::genDefaultSliceShaderString(bool lighting,
shader += addLighting(nvol);

//------------------
if (peel && peelType!=2)
if (peel)
{
if (!lighting)
{
Expand Down Expand Up @@ -564,11 +564,6 @@ ShaderFactory2::genDefaultSliceShaderString(bool lighting,
shader += QString(" val1 = one-smoothstep(peelMinSub, peelMin, vIdotN);\n");
shader += QString(" val1 *= smoothstep(peelMax, peelMaxPlus, vIdotN);\n");
}
// else
// { //---- keep outside
// shader += QString(" val1 = smoothstep(peelMinSub, peelMin, vIdotN);\n");
// shader += QString(" val1 = max(val1, (one - smoothstep(peelMax, peelMaxPlus, vIdotN)));\n");
// }

shader += QString(" vIdotN = mix(val1, one, peelMix);\n").arg(peelMix);

Expand Down Expand Up @@ -897,7 +892,7 @@ ShaderFactory2::genHighQualitySliceShaderString(bool lighting,
shader += addLighting(nvol);

//------------------
if (peel && peelType!=2)
if (peel)
{
if (!lighting)
{
Expand Down Expand Up @@ -956,11 +951,6 @@ ShaderFactory2::genHighQualitySliceShaderString(bool lighting,
shader += QString(" val1 = one-smoothstep(peelMinSub, peelMin, vIdotN);\n");
shader += QString(" val1 *= smoothstep(peelMax, peelMaxPlus, vIdotN);\n");
}
// else
// { //---- keep outside
// shader += QString(" val1 = smoothstep(peelMinSub, peelMin, vIdotN);\n");
// shader += QString(" val1 = max(val1, (one - smoothstep(peelMax, peelMaxPlus, vIdotN)));\n");
// }

shader += QString(" vIdotN = mix(val1, one, peelMix);\n").arg(peelMix);

Expand Down Expand Up @@ -1019,9 +1009,6 @@ ShaderFactory2::genHighQualitySliceShaderString(bool lighting,
if (tearPresent || cropPresent || pathCropPresent)
shader += " gl_FragColor.rgba = mix(gl_FragColor.rgba, vec4(0.0,0.0,0.0,0.0), feather);\n";

if (shadows && peel && peelType == 2)
shader += " gl_FragColor.rgba *= peelfeather;\n";

//------------------------------------
shader += "gl_FragColor = 1.0-pow((vec4(1,1,1,1)-gl_FragColor),";
shader += "vec4(lod,lod,lod,lod));\n";
Expand Down Expand Up @@ -1210,7 +1197,7 @@ ShaderFactory2::genSliceShadowShaderString(float shadowintensity,


//------------------
if (peel && peelType!=2)
if (peel)
{

shader += QString(" if (grad1 > 0.0)\n");
Expand Down Expand Up @@ -1267,11 +1254,6 @@ ShaderFactory2::genSliceShadowShaderString(float shadowintensity,
shader += QString(" val1 = one-smoothstep(peelMinSub, peelMin, vIdotN);\n");
shader += QString(" val1 *= smoothstep(peelMax, peelMaxPlus, vIdotN);\n");
}
// else
// { //---- keep outside
// shader += QString(" val1 = smoothstep(peelMinSub, peelMin, vIdotN);\n");
// shader += QString(" val1 = max(val1, (one - smoothstep(peelMax, peelMaxPlus, vIdotN)));\n");
// }

shader += QString(" vIdotN = mix(val1, one, peelMix);\n").arg(peelMix);

Expand Down Expand Up @@ -1336,12 +1318,6 @@ ShaderFactory2::genSliceShadowShaderString(float shadowintensity,
if (tearPresent || cropPresent || pathCropPresent)
shader += " gl_FragColor.rgba = mix(gl_FragColor.rgba, vec4(0.0,0.0,0.0,0.0), feather);\n";

if (peel && peelType==2)
{
float reduceShadow = 1.0f - qBound(0.0f, (peelMin+1.0f)*0.5f, 1.0f);
shader += QString(" gl_FragColor.rgba = mix(gl_FragColor.rgba, vec4(0.0,0.0,0.0,0.0), float(%1));\n").\
arg(reduceShadow);
}

//------------------------------------
shader += "gl_FragColor = 1.0-pow((vec4(1,1,1,1)-gl_FragColor),";
Expand Down
28 changes: 3 additions & 25 deletions drishti/shaderfactoryrgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ ShaderFactoryRGB::genDefaultSliceShaderString(bool lighting,
shader += addLighting();

//------------------
if (peel && peelType!=2)
if (peel)
{
if (!lighting)
{
Expand All @@ -376,11 +376,6 @@ ShaderFactoryRGB::genDefaultSliceShaderString(bool lighting,
shader += QString(" float val1 = 1.0-smoothstep(float(%1)-0.1, float(%1), IdotN);\n").arg(peelMin);
shader += QString(" val1 *= smoothstep(float(%1), float(%1)+0.1, IdotN);\n").arg(peelMax);
}
// else
// { //---- keep outside
// shader += QString(" float val1 = smoothstep(float(%1)-0.1, float(%1), IdotN);\n").arg(peelMin);
// shader += QString(" val1 = max(val1, (1.0 - smoothstep(float(%1), float(%1)+0.1, IdotN)));\n").arg(peelMax);
// }

shader += QString(" IdotN = mix(val1, 1.0, float(%1));\n").arg(peelMix);
shader += " gl_FragColor.rgba *= IdotN;\n";
Expand Down Expand Up @@ -564,7 +559,7 @@ ShaderFactoryRGB::genHighQualitySliceShaderString(bool lighting,
shader += addLighting();

//------------------
if (peel && peelType!=2)
if (peel)
{
if (!lighting)
{
Expand All @@ -586,11 +581,6 @@ ShaderFactoryRGB::genHighQualitySliceShaderString(bool lighting,
shader += QString(" float val1 = 1.0-smoothstep(float(%1)-0.1, float(%1), IdotN);\n").arg(peelMin);
shader += QString(" val1 *= smoothstep(float(%1), float(%1)+0.1, IdotN);\n").arg(peelMax);
}
// else
// { //---- keep outside
// shader += QString(" float val1 = smoothstep(float(%1)-0.1, float(%1), IdotN);\n").arg(peelMin);
// shader += QString(" val1 = max(val1, (1.0 - smoothstep(float(%1), float(%1)+0.1, IdotN)));\n").arg(peelMax);
// }

shader += QString(" IdotN = mix(val1, 1.0, float(%1));\n").arg(peelMix);
shader += " gl_FragColor.rgba *= IdotN;\n";
Expand Down Expand Up @@ -816,7 +806,7 @@ ShaderFactoryRGB::genSliceShadowShaderString(float r, float g, float b,
shader += " gl_FragColor.rgba = mix(gl_FragColor.rgba, vec4(0.0,0.0,0.0,0.0), feather);\n";
//---------------------

if (peel && peelType!=2)
if (peel)
{
shader += getNormal();
shader += " vec3 voxpos = pointpos;\n";
Expand All @@ -836,24 +826,12 @@ ShaderFactoryRGB::genSliceShadowShaderString(float r, float g, float b,
shader += QString(" float val1 = 1.0-smoothstep(float(%1)-0.1, float(%1), IdotN);\n").arg(peelMin);
shader += QString(" val1 *= smoothstep(float(%1), float(%1)+0.1, IdotN);\n").arg(peelMax);
}
// else
// { //---- keep outside
// shader += QString(" float val1 = smoothstep(float(%1)-0.1, float(%1), IdotN);\n").arg(peelMin);
// shader += QString(" val1 = max(val1, (1.0 - smoothstep(float(%1), float(%1)+0.1, IdotN)));\n").arg(peelMax);
// }

shader += QString(" IdotN = mix(val1, 1.0, float(%1));\n").arg(peelMix);
shader += " gl_FragColor.rgba *= IdotN;\n";
}
//------------------

if (peel && peelType==2)
{
float reduceShadow = 1.0f - qBound(0.0f, (peelMin+1.0f)*0.5f, 1.0f);
shader += QString(" gl_FragColor.rgba = mix(gl_FragColor.rgba, vec4(0.0,0.0,0.0,0.0), float(%1));\n").\
arg(reduceShadow);
}


shader += QString(" gl_FragColor.rgba *= vec4(%1, %2, %3, %4);\n").\
arg(r).arg(g).arg(b).arg(maxrgb);
Expand Down
6 changes: 6 additions & 0 deletions drishti/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3403,6 +3403,12 @@ Viewer::processLight(QStringList list)
else
pts = GeometryObjects::hitpoints()->points();

if (pts.count() == 0)
{
QMessageBox::information(0, "Error", "Need atleast one point to add a light");
return;
}

if (list[0] == "addplight")
LightHandler::giLights()->addGiPointLight(pts);
else
Expand Down

0 comments on commit 86c3c0f

Please sign in to comment.