Commit 66c369b1 authored by Michele Bosi's avatar Michele Bosi

Vivid "alpha" settings renamed "opacity"

parent 4efd21d3
......@@ -23,7 +23,7 @@ void main()
if ( vl_Vivid.stencil.enabled ) {
gl_FragColor.rgb = frontColor.rgb + vl_Vivid.stencil.backgroundColor.rgb * frontColor.a;
gl_FragColor.a = vl_Vivid.alpha;
gl_FragColor.a = vl_Vivid.opacity;
float stencil = texture2DRect(vl_Vivid.stencil.texture, gl_FragCoord.xy ).r;
// uncomment to smooth only the "inside" of the stencil
......@@ -41,6 +41,6 @@ void main()
gl_FragColor.a *= stencil;
} else {
gl_FragColor.rgb = frontColor.rgb;
gl_FragColor.a = ( 1.0 - frontColor.a ) * vl_Vivid.alpha;
gl_FragColor.a = ( 1.0 - frontColor.a ) * vl_Vivid.opacity;
}
}
......@@ -31,7 +31,7 @@ void main()
if ( stencil > 0 && stencil < squared ) {
gl_FragColor = vl_Vivid.outline.color;
gl_FragColor.a *= vl_Vivid.alpha;
gl_FragColor.a *= vl_Vivid.opacity;
return;
}
}
......
......@@ -114,9 +114,10 @@ struct vl_VividParameters {
// Requires enableTextureMapping=1
bool enablePointSprite;
// <automatic>
// <automatic>
// Global opacity
float alpha;
float opacity;
// <automatic>
vl_StencilParameters stencil;
......
......@@ -554,16 +554,16 @@ public:
saveActor( this->mVividRendering->sceneManager()->tree()->actors()->at(0) );
break;
case 'a': {
float opacity = mVividRendering->alpha() - 0.025f;
float opacity = mVividRendering->opacity() - 0.025f;
opacity = max(opacity, 0.0f);
mVividRendering->setAlpha( opacity );
mVividRendering->setOpacity( opacity );
printf("opacity: %f\n", opacity);
}
break;
case 'd': {
float opacity = mVividRendering->alpha() + 0.025f;
float opacity = mVividRendering->opacity() + 0.025f;
opacity = min(opacity, 1.0f);
mVividRendering->setAlpha( opacity );
mVividRendering->setOpacity( opacity );
printf("opacity: %f\n", opacity);
}
break;
......
......@@ -414,11 +414,11 @@ void VividRenderer::renderStencil(Camera* camera) {
//-------------------------------------------------------------------------------------------------
void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Camera* camera, real frame_clock)
{
mShaderOutline2D->gocUniform("vl_Vivid.alpha")->setUniform( mVividRendering->alpha() );
mShaderOutline2D->gocUniform("vl_Vivid.opacity")->setUniform( mVividRendering->opacity() );
mShaderOutline3D->gocUniform("vl_Vivid.outline.eyeOffset")->setUniform( mVividRendering->outline3DEyeOffset() );
mShaderOutline3D->gocUniform("vl_Vivid.outline.clipOffset")->setUniform( mVividRendering->outline3DClipOffset() );
mShaderOutline3D->gocUniform("vl_Vivid.alpha")->setUniform( mVividRendering->alpha() );
//mShaderOutline3D->gocUniform("vl_Vivid.opacity")->setUniform( mVividRendering->opacity() );
//mShaderFrontInit_S->gocUniform("vl_Vivid.outline.eyeOffset")->setUniform( mOutline3DEyeOffset );
//mShaderFrontInit_S->gocUniform("vl_Vivid.outline.clipOffset")->setUniform( mOutline3DClipOffset );
......@@ -426,7 +426,7 @@ void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Ca
//mShaderFrontPeel_S->gocUniform("vl_Vivid.outline.eyeOffset")->setUniform( mOutline3DEyeOffset );
//mShaderFrontPeel_S->gocUniform("vl_Vivid.outline.clipOffset")->setUniform( mOutline3DClipOffset );
mShaderFrontFinal->gocUniform("vl_Vivid.alpha")->setUniform( mVividRendering->alpha() );
mShaderFrontFinal->gocUniform("vl_Vivid.opacity")->setUniform( mVividRendering->opacity() );
mShaderFrontFinal->gocUniform("vl_Vivid.stencil.enabled")->setUniformI( mVividRendering->stencilEnabled() );
mShaderFrontFinal->gocUniform("vl_Vivid.stencil.smoothness")->setUniform( mVividRendering->stencilSmoothness() );
mShaderFrontFinal->gocUniform("vl_Vivid.stencil.backgroundColor")->setUniform( mVividRendering->stencilBackground() );
......
......@@ -55,7 +55,7 @@ VividRendering::VividRendering() {
mRenderingMode = DepthPeeling;
mAlpha = 1.0f;
mOpacity = 1.0f;
mOutline3DEyeOffset = 0.0f; // 0.25mm works well with VTK
mOutline3DClipOffset = 0.0f; // 0.0005 is more general but can create artifacts
......
......@@ -84,8 +84,10 @@ namespace vl
void setRenderingMode(ERenderingMode mode) { mRenderingMode = mode; }
ERenderingMode renderingMode() const { return mRenderingMode; }
void setAlpha( float a ) { mAlpha = a; }
float alpha() const { return mAlpha; }
/** The opacity of the 3D rendering on top of the background. */
void setOpacity( float a ) { mOpacity = a; }
/** The opacity of the 3D rendering on top of the background. */
float opacity() const { return mOpacity; }
// Outline settings
......@@ -164,7 +166,7 @@ namespace vl
ERenderingMode mRenderingMode;
float mAlpha;
float mOpacity;
bool mStencilEnabled;
std::vector< ref<Actor> > mStencilActors;
......
......@@ -132,7 +132,7 @@ VividVolume::VividVolume(VividRendering* vivid_rendering)
bindActor( mVolumeActor.get() );
mVolumeActor->setEffect( mVolumeFX.get() );
mVolumeActor->setTransform( mVolumeTransform.get() );
mVolumeActor->gocUniform( "vl_Vivid.alpha" )->setUniform( mVividRendering->alpha() );
mVolumeActor->gocUniform( "vl_Vivid.opacity" )->setUniform( mVividRendering->opacity() );
// do not read nor write the depth buffer - we do it in the shader
mVolumeFX->shader()->disable( EN_DEPTH_TEST );
......@@ -208,8 +208,8 @@ void VividVolume::updateUniforms( vl::Actor*actor, vl::real, const vl::Camera* c
vec3 volumeScalingCorrection = vec3(1,1,1) / (boxdim / min_size);
actor->gocUniform( "volumeScalingCorrection" )->setUniform( volumeScalingCorrection );
// vl_Vivid.alpha
actor->gocUniform( "vl_Vivid.alpha" )->setUniform( mVividRendering->alpha() );
// vl_Vivid.opacity
actor->gocUniform( "vl_Vivid.opacity" )->setUniform( mVividRendering->opacity() );
// volume bounding box min & max corners
actor->gocUniform( "volumeBoxMin" )->setUniform( box().minCorner() );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment