Commit df881fe8 authored by Michele Bosi's avatar Michele Bosi

Vivid: per-Shader outline width

parent 6b85d5b3
......@@ -51,17 +51,17 @@ struct vl_SmartClipParameters {
// Outline
struct OutlineParameters {
// <per-Actor>
// <per-Shader>
// Clipping plane for Slice Outline mode in World Coordinates
vec4 slicePlane;
// <per-Actor>
// <per-Shader>
// Outline color
vec4 color;
// <automatic>
// <per-Shader>
// Outline width
float width;
int width;
// <automatic>
// Offset in camera space
......@@ -97,19 +97,19 @@ struct vl_StencilParameters {
};
struct vl_VividParameters {
// <per-Actor>
// <per-Shader>
// 0=Polys, 1=Outline3D, 2=Polys+Outline3D, 3=Slice, 4=Outline2D, 5=Polys+Outline2D
int renderMode;
// <per-Actor>
// <per-Shader>
// If lighting is disabled Geometry must have a color array
bool enableLighting;
// <per-Actor>
// <per-Shader>
// Whether to use texture mapping or not
bool enableTextureMapping;
// <per-Actor>
// <per-Shader>
// Whether to render points as textured point sprites
// Requires enableTextureMapping=1
bool enablePointSprite;
......@@ -121,13 +121,13 @@ struct vl_VividParameters {
// <automatic>
vl_StencilParameters stencil;
// <automatic> / <per-Actor>
// <automatic> / <per-Shader>
OutlineParameters outline;
// <per-Actor>
// <per-Shader>
vl_SmartFogParameters smartFog;
// <per-Actor>
// <per-Shader>
vl_SmartClipParameters smartClip[ VL_SMART_CLIP_SIZE ];
};
......
......@@ -127,7 +127,7 @@ void VividRenderer::lazyInitialize()
glGenQueries(1, &mQueryID);
initGLBuffers();
initShaders();
} else
} else
if ( mImageSize.x() < fb_size.x() || mImageSize.y() < fb_size.y() ) {
// Resize only if larger
mImageSize = fb_size;
......@@ -412,7 +412,6 @@ void VividRenderer::renderStencil(Camera* camera) {
//-------------------------------------------------------------------------------------------------
void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Camera* camera, real frame_clock)
{
mShaderOutline2D->gocUniform("vl_Vivid.outline.width")->setUniform( mVividRendering->outlineWidth() );
mShaderOutline2D->gocUniform("vl_Vivid.alpha")->setUniform( mVividRendering->alpha() );
mShaderOutline3D->gocUniform("vl_Vivid.outline.eyeOffset")->setUniform( mVividRendering->outline3DEyeOffset() );
......@@ -581,7 +580,7 @@ void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Ca
// 3D Outlines & Slicing
// FIXME:
// FIXME:
// We still have to decide how we want the 3D oulines to interact with the z-buffer
// draw buffer
......@@ -756,7 +755,6 @@ void VividRenderer::renderQueue(const RenderQueue* render_queue, GLSLProgram* cu
if ( outline_on ) {
glEnable( GL_LINE_SMOOTH );
glHint( GL_LINE_SMOOTH_HINT, GL_NICEST );
glLineWidth( mVividRendering->outlineWidth() );
}
for(int itok=0; itok < render_queue->size(); ++itok)
......@@ -813,7 +811,7 @@ void VividRenderer::renderQueue(const RenderQueue* render_queue, GLSLProgram* cu
// texture mapping
if( shader->getUniform("vl_Vivid.enableTextureMapping")->getUniformI() == 1 ) {
shader->getTextureSampler( vl::VividRendering::UserTexture )->apply(vl::VividRendering::UserTexture, NULL, opengl_context);
shader->getTextureSampler( vl::VividRendering::UserTexture )->apply(vl::VividRendering::UserTexture, NULL, opengl_context);
VL_CHECK_OGL();
} else {
TextureSampler::reset(vl::VividRendering::UserTexture, opengl_context);
......@@ -830,6 +828,15 @@ void VividRenderer::renderQueue(const RenderQueue* render_queue, GLSLProgram* cu
}
if ( cur_glsl && shader->getUniformSet() ) {
cur_glsl->applyUniformSet( shader->getUniformSet() );
if ( outline_on ) {
if ( shader->getUniformSet()->getUniform("vl_Vivid.outline.width") ) {
glLineWidth( shader->getUniformSet()->getUniform("vl_Vivid.outline.width")->getUniformI() );
} else {
// this should never happen
glLineWidth( 1 );
VL_TRAP();
}
}
}
/* These two states are managed by the Depth Peeling algorithm */
......@@ -885,7 +892,7 @@ const RenderQueue* VividRenderer::render(const RenderQueue* render_queue, Camera
lazyInitialize();
mPassCounter = 0;
if (!shadersReady()) {
return NULL;
}
......
......@@ -55,8 +55,6 @@ VividRendering::VividRendering() {
mRenderingMode = FrontToBackDepthPeeling;
mOutlineWidth = 2;
mAlpha = 1.0f;
mOutline3DEyeOffset = 0.0f; // 0.25mm works well with VTK
......@@ -127,6 +125,7 @@ ref<Effect> VividRendering::makeVividEffect(Effect* effect) {
// Outline
fx->shader()->gocUniform("vl_Vivid.renderMode")->setUniformI( 0 ); // 0=Polys, 1=Outline3D, 2=Polys+Outline3D, 3=Slice, 4=Outline2D, 5=Polys+Outline2D
fx->shader()->gocUniform("vl_Vivid.outline.color")->setUniform( vl::white );
fx->shader()->gocUniform("vl_Vivid.outline.width")->setUniformI( 2 );
fx->shader()->gocUniform("vl_Vivid.outline.slicePlane")->setUniform( vl::vec4( 1, 0, 0, 0 ) );
// Smart Fog: all the other settings are taken from the standard Fog object
......@@ -136,8 +135,8 @@ ref<Effect> VividRendering::makeVividEffect(Effect* effect) {
// Smart Clipping
for( char i = '0'; i < '4'; ++i ) {
fx->shader()->gocUniform((std::string("vl_Vivid.smartClip[") + i + "].mode").c_str())->setUniformI( 0 ); // 0=OFF, 1=Sphere, 2=Box, 3=Plane
fx->shader()->gocUniform((std::string("vl_Vivid.smartClip[") + i + "].fadeRange").c_str())->setUniformF( 0.0 ); // 0=Sharp, 0...X=Fuzzy
fx->shader()->gocUniform((std::string("vl_Vivid.smartClip[") + i + "].target").c_str())->setUniformI( 0 ); // 0=Color, 1=Alpha, 2=Saturation
fx->shader()->gocUniform((std::string("vl_Vivid.smartClip[") + i + "].fadeRange").c_str())->setUniformF( 0.0 ); // 0=Sharp, 0...X=Fuzzy
fx->shader()->gocUniform((std::string("vl_Vivid.smartClip[") + i + "].color").c_str())->setUniform( vl::black );
fx->shader()->gocUniform((std::string("vl_Vivid.smartClip[") + i + "].plane").c_str())->setUniform( vl::vec4( 0, 0, 0, 0 ) ); // Plane Nx, Ny, Nz, Pd (distance from origin) (World Coords)
fx->shader()->gocUniform((std::string("vl_Vivid.smartClip[") + i + "].sphere").c_str())->setUniform( vl::vec4( 0, 0, 0, 0 ) ); // Sphere X, Y, Z, Radius (World Coords)
......
......@@ -89,9 +89,6 @@ namespace vl
// Outline settings
void setOutlineWidth( float w ) { mOutlineWidth = w; }
float outlineWidth() const { return mOutlineWidth; } ;
/** Offset outline by given amount in camera space to make it more visible. Only for `Outline3D` modes. */
void setOutline3DEyeOffset( float offset ) { mOutline3DEyeOffset = offset; }
/** Offset outline by given amount in camera space to make it more visible. Only for `Outline3D` modes. */
......@@ -179,7 +176,6 @@ namespace vl
int mStencilSmoothness;
vec4 mStencilBackground;
float mOutlineWidth;
float mOutline3DClipOffset;
float mOutline3DEyeOffset;
......
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