[vtkusers] [Try Again] Multiple Volumes with one Renderer
"Johannes Käfer"
jak4.scr at gmx.net
Fri Oct 22 14:06:33 EDT 2004
Okay answering my own question.
I had to modify two files in order to get the desired result.
1) vtkWin32OpenGLRenderWindow.cxx
There I had to enable the stencil buffer (which was disabled). In the
function void vtkWin32OpenGLRenderWindow::SetupPixelFormat(...) I had to put
"1" instead of "0" into the line with the comment /* no stencil buffer */
(parameter 12).
2) VtkRenderer.cxx
There I made modifications to the "int vtkRenderer::UpdateGeometry()"
function. The changes were made before and in the second for loop (rendering
translucent geometry). See the code below.
// enable some opengl commands, so we achieve the effect of
// translucent volumes but not beeing able to see a volume lying behind
// another volume
glEnable(GL_DEPTH_TEST);
// the stencil test basically writes to a different buffer than the frame
buffer
// and based on the values in the stencil buffer we write a pixel to the
frame buffer or we don't
glEnable(GL_STENCIL_TEST);
// we only write to the frame/stencil buffer if the value in the stencil
buffer is 0x0 (zero)
glStencilFunc(GL_NOTEQUAL, 0x1, 0xff);
// when drawing, replace the value in the stencil buffer
glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
// reset the stencil buffer to all zeros (we can draw everywhere)
glClearStencil(0x0);
// needed
glClear(GL_STENCIL_BUFFER_BIT);
// loop through props and give them a chance to
// render themselves as translucent geometry
for ( i = 0; i < this->PropArrayCount; i++ ){
// we need to do this in here because after the RenderTranslucentGeometry
the alpha test is
// not enabled any more
// we need the alpha test too, so we can "blend out" the black area
surrounding our object
glEnable(GL_ALPHA_TEST);
// draw only pixels with a alpha value greater than 0.00001, this should
also work with zero
// as the background should have zero alpha but it doesn't (maybe float
inaccurancy)
glAlphaFunc(GL_GREATER, 0.00001);
this->NumberOfPropsRendered +=
this->PropArray[i]->RenderTranslucentGeometry(this);
}
// disable the stencil and alpha test
glDisable(GL_STENCIL_TEST);
glDisable(GL_ALPHA_TEST);
Hope this helps someone.
Regards
Johannes
> Hi,
>
> I'm trying to render two or more Volumes with one Renderer. I don't want
> to
> be able to see a volume lying behind the volume in front. Can someone give
> me a hint?
>
> More detailed. I'm rendering two volumes in one renderer as said above.
> This
> works quite nice. I'm using the vtkVolumeRayCastMapper with the
> vtkVolumeRayCastCompositeFunction.
> The Volumes I render are quite translucent so when I have two volumes I
> can
> see the volume lying behind the first one. I don't want this to happen. I
> want to stop the raycasting when I enter a new Volume. Is there any way
> this
> can be done/ has already been done? If not were to start modifying vtk in
> order to get it done.
>
> Thank you for your help.
>
> best regards
> Johannes
> Regards
> Johannes
>
>
> --
> GMX ProMail mit bestem Virenschutz http://www.gmx.net/de/go/mail
> +++ Empfehlung der Redaktion +++ Internet Professionell 10/04 +++
>
> _______________________________________________
> This is the private VTK discussion list.
> Please keep messages on-topic. Check the FAQ at:
> <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
--
+++ GMX DSL Premiumtarife 3 Monate gratis* + WLAN-Router 0,- EUR* +++
Clevere DSL-Nutzer wechseln jetzt zu GMX: http://www.gmx.net/de/go/dsl
More information about the vtkusers
mailing list