[vtkusers] Request to VTK Multi-Pass Rendering

Rocco Gasteiger post at rocco-gasteiger.de
Mon Nov 23 04:50:44 EST 2009


Dear VTK users,

 

I want to use the new mulit-pass framework in VTK implemented by François
Bertel. At first, many thanks François for implementing this framework! I
need some multipass rendering for my research project and I think you have
provided a very good base for start-up with this. 

 

For a better understanding how it works, I tried to adopt a native
multi-pass OpenGL example in VTK, with help of the given framework. In doing
so I oriented me at the given examples on the according VTK Wiki sites.
Unfortunately, I did not get the same result in VTK like in OpenGL. I think
I miss some important facts of understanding the VTK rendering pipeline. So
I hope somebody (maybe François directly) can help me to have a better
understanding of how the framework works.  Here comes what I really do:

 

In OpenGL I implemented an algorithm for hidden line removing (It is based
on the paper of Jarek R. Rossignac and Maarten van Emerik: Hidden contours
on a frame-buffer (1992) ). Here is a snippet of my OpenGL code, where I
have to render my geometry two times (2-passes).

 

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnable(GL_DEPTH_TEST);

glColor3f(0,0,0);

 

// Settings for first pass

glColorMask(GL_FALSE, GL_FALSE, GL_FALSE,GL_FALSE);

glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);

drawMyGeometryWithSolidFaces();

 

// Settings for second pass

glColorMask(GL_TRUE, GL_TRUE, GL_TRUE,GL_TRUE);

glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);

glEnable(GL_POLYGON_OFFSET_LINE);

glPolygonOffset(-1.0,1.0);

drawMyGeometryWithSolidFaces();

 

// Reset polygon offsest

glDisable(GL_POLYGON_OFFSET_FILL);

 

 

In VTK I derived a class “vtkHiddenLineDesignerPass” from “vtkRenderPass”
and tried to implement the same OpenGL steps. The result is, that still all
lines are rendered, also the hidden lines. I use the following lines of code
snippets in the “Render(const vtkRenderState *s)”-function to adopt the
OpenGL-code with VTK datastructures and calls:

 

//** Getting necessary VTK-objects to turn on/off some OpenGL-states.**/

vtkOpenGLRenderer *r=static_cast<vtkOpenGLRenderer *>(s->GetRenderer());

vtkActor *actor = r->GetActors()->GetLastActor();

vtkPolyDataMapper *actorMapper =
static_cast<vtkPolyDataMapper*>(actor->GetMapper());

vtkProperty *actorProp = actor->GetProperty();

                               

// Settings for the first pass //

glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glColorMask(GL_FALSE, GL_FALSE, GL_FALSE,GL_FALSE);

actorProp->SetRepresentationToSurface(); //** For
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);**//

this->DelegatePass->Render(s);

this->NumberOfRenderedProps +=
this->DelegatePass->GetNumberOfRenderedProps();

 

// Settings for the second pass //

actorProp->SetDiffuseColor(0,0,0); //** For glColor3f(0,0,0); **//

glColorMask(GL_TRUE, GL_TRUE, GL_TRUE,GL_TRUE);

actorProp->SetRepresentationToWireframe();  //** For
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); **//

actorMapper->SetResolveCoincidentTopology(1);

actorMapper->SetResolveCoincidentTopologyToPolygonOffset();

actorMapper->SetResolveCoincidentTopologyPolygonOffsetFaces(0); //** For
glEnable(GL_POLYGON_OFFSET_LINE);**//

actorMapper->SetResolveCoincidentTopologyPolygonOffsetParameters(-1.0,1);
//** For glPolygonOffset(-1.0,1.0);**//

                

this->DelegatePass->Render(s);

this->NumberOfRenderedProps +=
this->DelegatePass->GetNumberOfRenderedProps();

actorMapper->SetResolveCoincidentTopology(0); //** For
glDisable(GL_POLYGON_OFFSET_FILL);**//

 

 

In my VTK-class, where I use this rendering pass, I process following
rendering pipeline:

// The elementary passes.

vtkLightsPass *lights=vtkLightsPass::New();

vtkDefaultPass *defaultPass=vtkDefaultPass::New();

                

// Put them in a sequence.

vtkRenderPassCollection *passes=vtkRenderPassCollection::New();

passes->AddItem(lights);

passes->AddItem(defaultPass);

 

vtkSequencePass *seq=vtkSequencePass::New();

seq->SetPasses(passes);

 

// Make the sequence the delegate of a camera pass.

vtkCameraPass *cameraP=vtkCameraPass::New();

cameraP->SetDelegatePass(seq);

 

// Create the hidden line removing pass and attach the camera pass as its
delegate

vtkHiddenLineDesignerPass *myPass=vtkHiddenLineDesignerPass::New();

myPass ->SetDelegatePass(cameraP);

                

vtkRenderer* renderer01= vtkRenderer::New();

renderer01->SetPass(myPass);

 

 

Especially, my misunderstanding relies on when to use native OpenGL-code and
when using VTK-calls. I tried some variations of  the code, presented above
but without success. It would be very helpful if someone can give me some
hints.

 

Many thanks in advance,

Rocco Gasteiger 

 

 

--------------------------------------------------

Dipl.-Ing. Rocco Gasteiger

Otto-von-Guericke University
Faculty of Computer Science
Department of Simulation and Graphics
Universitätsplatz 2, 39106 Magdeburg, Germany

 

Office:  G29-223

Phone:   +49 391 67 127 59
Fax:     +49 391 67 111 64

Website: http://wwwisg.cs.uni-magdeburg.de/cvcms/  

--------------------------------------------------

 

 

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091123/6523474e/attachment.htm>


More information about the vtkusers mailing list