[vtkusers] Re: Problem with alpha blending
Francisco Jesús Martínez Serrano
franjesus at gmail.com
Fri Jul 13 10:50:35 EDT 2007
I finished the visualization program with vtk, here are some results:
http://es.youtube.com/watch?v=MEEd3oOf9To
I think it's a nice application of VTK (what can I say, I'm the father).
Many thanks for the software!!!
2007/7/6, Francisco Jesús Martínez Serrano:
>
> I found the problem: VTK was using the opaque codepath to render my
> geometry. The following quick and dirty hack solved it:
>
> actor->GetProperty()->SetOpacity(0.999999);
>
>
> 2007/7/6, Francisco Jesús Martínez Serrano:
> > Dear vtk users,
> >
> > I'm trying to create an application to visualize the results of
> > galaxy-formation simulations
> > using particles. The technique that I want to use is the technique
> > that was used to make
> > these videos:
> >
> > http://www.aip.de/People/AKhalatyan/COSMOLOGY/STEREO/MW_ANDROMEDA/MW.htm
> >
> > It is basically a billboarding using a texture for each particle that
> > reproduces the density field of each particle.
> >
> > The billboarding implementation that I have so far consists of adding
> > all the particles as
> > input of a vtkGlyph3D object and a vtkPlaneSource as source. The
> > texture (consisting of a
> > white square R=G=B=255 with varying alpha value for transparency) is
> > then added to the
> > actor of the vtkPolyDataMapper of the glyph. I have set up a callback
> > that sets the normal
> > vector of each plane in the glyph directed towards the camera:
> >
> > void OrientNormal( vtkObject* vtkNotUsed(object),unsigned long
> > eventId,void* sr,void* vtkNotUsed(calldata))
> > {
> > CallbackData* cd = reinterpret_cast<CallbackData*>(sr);
> > vtkCamera* cam = cd->cam;
> > vtkPolyData* pdata = cd->pdata;
> > vtkPointData *PD = pdata->GetPointData();
> > vtkGlyph3D* glyph = cd->glyph;
> >
> > double *rz;
> > double rzm[3],rym[3],rxm[3];
> > double *pos;
> > double *cpos = cam->GetPosition();
> > // Vector data for directions
> > vtkFloatArray *FA = vtkFloatArray::New();
> > FA->SetName("directions");
> > FA->SetNumberOfComponents(3);
> > uint n=pdata->GetNumberOfPoints();
> > for (uint i=0; i<n; i++)
> > {
> > if ( cam->GetParallelProjection() != 0 )
> > {
> > rz = cam->GetDirectionOfProjection();
> > rzm[0] = -rz[0];
> > rzm[1] = -rz[1];
> > rzm[2] = -rz[2];
> > }
> > else
> > {
> > pos=pdata->GetPoint(i);
> > rzm[0] = -cpos[0] + pos[0];
> > rzm[1] = -cpos[1] + pos[1];
> > rzm[2] = -cpos[2] + pos[2];
> > // vtkMath::Normalize(rzm);
> > }
> > FA->InsertNextTuple(rzm);
> > }
> > // Add the data arrays to the point data
> > PD->SetNormals(FA);
> > FA->Delete();
> > }
> >
> >
> > The problem comes with some relative postions of particles which don't
> > work as supposed.
> > An example can be seen at:
> >
> > http://franjesus.googlepages.com/alphaproblem.png
> >
> > Here the green particle is on the front (you can tell by the size, all
> > particles have the same
> > radius) and is partially covering the yellow and cyan particles. For
> > the yellow particle the
> > desired effect is obtained and there's a blended transition zone. With
> > the cyan particle, the
> > problem happens and the green particle totally covers it until the
> > alpha channel goes to zero
> > (ie. like a threshold).
> >
> > Is there any option of the renderer that I have to set so get it
> > working correctly?
> > Might it be a problem with the OpenGL implementation? (nvidia linux
> 9755)
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20070713/f4439466/attachment.htm>
More information about the vtkusers
mailing list