[vtkusers] RE Request to VTK Multi-Pass Rendering
Stephane PLOIX
stephane.ploix at edf.fr
Tue Nov 24 05:58:09 EST 2009
Hi Rocco,
Here is a general picture of the different ways you can implement advanced
rendering effects in VTK :
*shaders : each vtkProp can have a shader, this is mostly used in single
pass algorithms
*painters : you can implement a per-prop multipass algorithm in a painter,
as is done in the plugin example in
ParaView/Example/Plugins/HiddenLinesRemoval which does exactly what you
need.
*renderpass : this framework is intended for algorithm that need global
information of all props : you can implement post-processing algorithms
like screen-space ambient occlusion or edge-detection filters, and
algorithms that require several passes of all the props, like shadow
mapping.
Best,
Stephane
post at rocco-gasteiger.de
Envoyé par : vtkusers-bounces at vtk.org
23/11/2009 10:51
A
vtkusers at vtk.org
cc
Objet
[vtkusers] Request to VTK Multi-Pass Rendering
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/
--------------------------------------------------
_______________________________________________
Powered by www.kitware.com
Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html
Please keep messages on-topic and check the VTK FAQ at:
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers
Ce message et toutes les pièces jointes (ci-après le 'Message') sont établis à l'intention exclusive des destinataires et les informations qui y figurent sont strictement confidentielles. Toute utilisation de ce Message non conforme à sa destination, toute diffusion ou toute publication totale ou partielle, est interdite sauf autorisation expresse.
Si vous n'êtes pas le destinataire de ce Message, il vous est interdit de le copier, de le faire suivre, de le divulguer ou d'en utiliser tout ou partie. Si vous avez reçu ce Message par erreur, merci de le supprimer de votre système, ainsi que toutes ses copies, et de n'en garder aucune trace sur quelque support que ce soit. Nous vous remercions également d'en avertir immédiatement l'expéditeur par retour du message.
Il est impossible de garantir que les communications par messagerie électronique arrivent en temps utile, sont sécurisées ou dénuées de toute erreur ou virus.
____________________________________________________
This message and any attachments (the 'Message') are intended solely for the addressees. The information contained in this Message is confidential. Any use of information contained in this Message not in accord with its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval.
If you are not the addressee, you may not copy, forward, disclose or use any part of it. If you have received this message in error, please delete it and all copies from your system and notify the sender immediately by return message.
E-mail communication cannot be guaranteed to be timely secure, error or virus-free.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091124/2a4393d6/attachment.htm>
More information about the vtkusers
mailing list