Commit 2732a6e6 authored by Michele Bosi's avatar Michele Bosi

3D outlines drawn inside the stencil and with depth buffer interaction

parent 66c369b1
......@@ -115,6 +115,9 @@ struct vl_VividParameters {
bool enablePointSprite;
// <automatic>
// Whether the current shader is rendering a 3D outline
bool outline3DRendering;
// <automatic>
// Global opacity
float opacity;
......
......@@ -145,45 +145,48 @@ void VividRenderer::initShaders()
//printf("\nLoading shaders...\n");
//float t0 = Time::currentTime();
mShaderFrontInit_S = new GLSLProgram();
//mShaderFrontPeel_S = new GLSLProgram();
// mShaderOutline3D = new GLSLProgram();
mShaderOutline2D = new GLSLProgram();
mShaderOutline3D = new GLSLProgram();
mShaderFrontInit = new GLSLProgram();
mShaderFrontPeel = new GLSLProgram();
mShaderFrontBlend = new GLSLProgram();
mShaderFrontFinal = new GLSLProgram();
mShaderOutline2D->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/outline2d_vertex.glsl" ) );
mShaderOutline2D->attachShader( new GLSLFragmentShader( SHADER_PATH "front_peeling/outline2d_fragment.glsl" ) );
mShaderOutline2D->linkProgram();
mShaderOutline3D->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/shade_vertex_outline.glsl" ) );
mShaderOutline3D->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/outline3d_fragment.glsl" ) );
mShaderOutline3D->attachShader( new GLSLGeometryShader(SHADER_PATH "front_peeling/outline.geom" ) );
mShaderOutline3D->linkProgram();
//mShaderOutline3D->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/shade_vertex_outline.glsl" ) );
//mShaderOutline3D->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/outline3d_fragment.glsl" ) );
//mShaderOutline3D->attachShader( new GLSLGeometryShader(SHADER_PATH "front_peeling/outline.geom" ) );
//mShaderOutline3D->linkProgram();
//mShaderFrontInit_S = new GLSLProgram();
//mShaderFrontPeel_S = new GLSLProgram();
mShaderFrontInit = new GLSLProgram();
mShaderFrontPeel = new GLSLProgram();
mShaderFrontBlend = new GLSLProgram();
mShaderFrontFinal = new GLSLProgram();
//mShaderFrontInit_S->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/shade_vertex_outline.glsl" ) );
//mShaderFrontInit_S->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/shade_fragment.glsl" ) );
//mShaderFrontInit_S->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/init_fragment.glsl" ) );
//mShaderFrontInit_S->attachShader( new GLSLGeometryShader(SHADER_PATH "front_peeling/outline.geom" ) );
//mShaderFrontInit_S->linkProgram();
mShaderFrontInit_S->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/shade_vertex_outline.glsl" ) );
mShaderFrontInit_S->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/shade_fragment.glsl" ) );
mShaderFrontInit_S->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/init_fragment.glsl" ) );
mShaderFrontInit_S->attachShader( new GLSLGeometryShader(SHADER_PATH "front_peeling/outline.geom" ) );
mShaderFrontInit_S->gocUniform("vl_Vivid.outline3DRendering")->setUniformI( 1 );
mShaderFrontInit_S->linkProgram();
//mShaderFrontPeel_S->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/shade_vertex_outline.glsl" ) );
//mShaderFrontPeel_S->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/shade_fragment.glsl" ) );
//mShaderFrontPeel_S->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/peel_fragment.glsl" ) );
//mShaderFrontPeel_S->attachShader( new GLSLGeometryShader(SHADER_PATH "front_peeling/outline.geom" ) );
//mShaderFrontPeel_S->gocUniform("vl_Vivid.outline3DRendering")->setUniformI( 1 );
//mShaderFrontPeel_S->linkProgram();
mShaderFrontInit->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/shade_vertex.glsl" ) );
mShaderFrontInit->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/shade_fragment.glsl" ) );
mShaderFrontInit->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/init_fragment.glsl" ) );
mShaderFrontInit->gocUniform("vl_Vivid.outline3DRendering")->setUniformI( 0 );
mShaderFrontInit->linkProgram();
mShaderFrontPeel->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/shade_vertex.glsl" ) );
mShaderFrontPeel->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/shade_fragment.glsl" ) );
mShaderFrontPeel->attachShader( new GLSLFragmentShader(SHADER_PATH "front_peeling/peel_fragment.glsl" ) );
mShaderFrontPeel->gocUniform("vl_Vivid.outline3DRendering")->setUniformI( 0 );
mShaderFrontPeel->linkProgram();
mShaderFrontBlend->attachShader( new GLSLVertexShader( SHADER_PATH "front_peeling/blend_vertex.glsl" ) );
......@@ -416,12 +419,12 @@ void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Ca
{
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.outline.eyeOffset")->setUniform( mVividRendering->outline3DEyeOffset() );
//mShaderOutline3D->gocUniform("vl_Vivid.outline.clipOffset")->setUniform( mVividRendering->outline3DClipOffset() );
//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 );
mShaderFrontInit_S->gocUniform("vl_Vivid.outline.eyeOffset")->setUniform( mVividRendering->outline3DEyeOffset() );
mShaderFrontInit_S->gocUniform("vl_Vivid.outline.clipOffset")->setUniform( mVividRendering->outline3DClipOffset() );
//mShaderFrontPeel_S->gocUniform("vl_Vivid.outline.eyeOffset")->setUniform( mOutline3DEyeOffset );
//mShaderFrontPeel_S->gocUniform("vl_Vivid.outline.clipOffset")->setUniform( mOutline3DClipOffset );
......@@ -449,12 +452,10 @@ void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Ca
mShaderFrontInit->applyUniformSet();
renderQueue( render_queue, mShaderFrontInit.get(), camera, frame_clock, true, false );
/*
// Outline 3D
mShaderFrontInit_S->useProgram();
mShaderFrontInit_S->applyUniformSet();
renderQueue( render_queue, mShaderFrontInit_S.get(), camera, frame_clock, true, true );
*/
glUseProgram( 0 );
......@@ -581,10 +582,7 @@ void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Ca
render2DOutlines( render_queue, camera, 0 );
// 3D Outlines & Slicing
// FIXME:
// We still have to decide how we want the 3D oulines to interact with the z-buffer
#if 0
// draw buffer
glBindFramebuffer( GL_FRAMEBUFFER, 0 );
glDrawBuffer( GL_BACK );
......@@ -594,6 +592,7 @@ void VividRenderer::renderFrontToBackPeeling(const RenderQueue* render_queue, Ca
mShaderOutline3D->useProgram();
mShaderOutline3D->applyUniformSet();
renderQueue( render_queue, mShaderOutline3D.get(), camera, frame_clock, true, true );
#endif
// Cleanup
......
......@@ -101,9 +101,9 @@ namespace vl
ivec2 mImageSize;
vl::ref<vl::GLSLProgram> mShaderOutline2D;
vl::ref<vl::GLSLProgram> mShaderOutline3D;
// vl::ref<vl::GLSLProgram> mShaderOutline3D;
// vl::ref<vl::GLSLProgram> mShaderFrontInit_S;
vl::ref<vl::GLSLProgram> mShaderFrontInit_S;
// vl::ref<vl::GLSLProgram> mShaderFrontPeel_S;
vl::ref<vl::GLSLProgram> mShaderFrontInit;
vl::ref<vl::GLSLProgram> mShaderFrontPeel;
......
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