[vtkusers] Problem with alpha blending

John Biddiscombe biddisco at cscs.ch
Fri Jul 6 07:59:58 EDT 2007


Francisco

http://www.cscs.ch/a-display.php?id=170

has an app you can use to do particle rendering using sprites or the 
GPU. For huge numbers of particles I'm adding the renderer to ParaView.
The mapper is located here (svn repository)
https://svn.cscs.ch/vtkContrib/trunk/vtkCSCS/vtkPointSprites/

This will allow millions of particles per second rendering speeds and 
transparency cn be handled too, (slows it down though).

JB


> 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)
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers


-- 
John Biddiscombe,                            email:biddisco @ cscs.ch
http://www.cscs.ch/about/BJohn.php
CSCS, Swiss National Supercomputing Centre  | Tel:  +41 (91) 610.82.07
Via Cantonale, 6928 Manno, Switzerland      | Fax:  +41 (91) 610.82.82





More information about the vtkusers mailing list