[vtkusers] Draw points with gaussian fade out

Michka Popoff michkapopoff at gmail.com
Thu Jun 20 09:35:50 EDT 2013


Thanks for your answers,

I try to fight my way through vtkFastSplatter, but there is only one example and I do not understand everything. (The documentation is a little sparse)
The example in the docs use a vtkImageViewer2,and I want to have a vtkactor to put it in my 3d scenery.
So I mapped the splatter on a vtkplane through a vtktexture (to be able to have a vtkactor). Hope this will not lead to performance problems once I try to display millions of vtkactors ...
It's also not really working, the colors are messed up, and I don't understand the vtkpoints usage for the vtkFastSplatter.

5 points are used in the example, which display 5 splats, but I was not able to have only one splat centered in the middle (even using only 1 point, at 0,0,0).


For vtkPointSpriteMapper, is not in vtk, so I have to find the way to take it from paraview, add it to vtk, and make the python bindings for it. Any idea how to achieve this ?


Regards

Michka


Le 19 juin 2013 à 23:29, Biddiscombe, John A. a écrit :

> Try googling vtkPointSpriteMapper
> A modified version using painters is in paraview, but the original was designed for straight vtk use.
> 
> JB 
> (apologies if you get multiple copies of this, email misfired)



Le 19 juin 2013 à 19:57, Markus Neuner a écrit :

> Hi,
> 
> oh vtkGaussianSplatter is the wrong class. It generates a volume, but you could visualize it with volume rendering.
> 
> The first version is basically what FastSplatter does (http://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/FastSplatter).
> 
> For the second version i can't find a class in vtk that can actually does this (compute the Gaussian directly in the fragment shader).
> 
> You can derive from vtkGLSLShaderProgram and implement the procedures described in this example http://prideout.net/blog/p60/Splat.zip written by Philip Rideout.
> 
> Regards,
> Markus
> 
> 
> On 06/16/2013 06:31 PM, Michka Popoff wrote:
>> Hi
>> 
>> thank you for your help.
>> 
>> 1) For the first solution, what would be the class to use to create the texture from the gaussian equation ? Once I have the textures, I could map them to planes. I did wrote some OpenGL code a while ago where I did this with a shader, billboarding the textures so that the gaussians would always face the camera. This was very fast.
>> 
>> 2) I saw vtkGaussianSplatter, but I don't know if I can set a different radius and exponent factor for each point ? In the class these values can only be set globally. I wrote some code (in python), inspired from the FinancialField example from vtkGaussianSplatter, but the splats are passed through vtkContourFilter to make a surface. I think this is messing with my gaussians, and I don't know how to do this without vtkContourFilter. I found no other example for vtkGaussianSplatter. Here is the code I wrote, displaying 10x10 points :
>> 
>> #!/usr/bin/env python
>> 
>> import vtk
>> from numpy import random
>> 
>> # Create points
>> points = vtk.vtkPoints()
>> for i in range(10):
>>     for j in range(10):
>>         points.InsertNextPoint(i, j, 0.0)
>> 
>> polydata = vtk.vtkPolyData()
>> polydata.SetPoints(points)
>> 
>> popSplatter = vtk.vtkGaussianSplatter()
>> popSplatter.SetInput(polydata)
>> popSplatter.SetSampleDimensions(50, 50, 50)
>> popSplatter.SetRadius(0.05)
>> popSplatter.ScalarWarpingOff()
>> popSplatter.Update()
>> 
>> popSurface = vtk.vtkContourFilter()
>> popSurface.SetInputConnection(popSplatter.GetOutputPort())
>> popSurface.SetValue(0, 0.01)
>> 
>> popMapper = vtk.vtkPolyDataMapper()
>> popMapper.SetInputConnection(popSurface.GetOutputPort())
>> popMapper.ImmediateModeRenderingOn()
>> 
>> popActor = vtk.vtkActor()
>> popActor.SetMapper(popMapper)
>> 
>> # Renderer
>> renderer = vtk.vtkRenderer()
>> renderer.AddActor(popActor)
>> renderer.ResetCamera()
>> 
>> # Render Window
>> renderWindow = vtk.vtkRenderWindow()
>> renderWindow.AddRenderer(renderer)
>> 
>> # Interactor
>> renderWindowInteractor = vtk.vtkRenderWindowInteractor()
>> renderWindowInteractor.SetRenderWindow(renderWindow)
>> 
>> # Begin Interaction
>> renderWindow.Render()
>> renderWindowInteractor.Start()
>> 
>> 
>> 
>> 
>> On 16 juin 2013, at 11:14, Markus Neuner <neuner.markus at gmx.net> wrote:
>> 
>>> Hi Michka,
>>> 
>>> You could try to generate volumetric data using Gaussian splats.
>>> 
>>> There are two solutions to this problem:
>>> - Create the 3D Gaussian function on the CPU during application initialization, and create a 3D texture from that.
>>> 
>>> - But better and much faster is to compute the Gaussian directly in the fragment shader.
>>> 
>>> Have a look at vtkGaussianSplatter it may do what you want.
>>> 
>>> Regards,
>>> Markus
>>> 
>>> 
>>> On 06/15/2013 05:18 PM, Michka Popoff wrote:
>>>> Hi
>>>> 
>>>> I want to draw a lot of points in VTK (~1.000.000), with each point's color fading out to a transparent value, following a gaussian function.
>>>> So the center will be bright (maximum intensity), and the border will have no color.
>>>> 
>>>> I am able to draw a lot of points using vtkPoints, I can also change their color, but I am looking for a way to apply the fade out to every point. Of course the parameters of the gaussian function will be different for each point (intensity value in the middle, diameter).
>>>> 
>>>> The result for 1 point would look like this : http://www.princeton.edu/~rvdb/images/deconv/Gauss2Psf.jpg
>>>> 
>>>> Are there some filters/mappers I could use directly ? Or can I perhaps try to "hijack" vtkgaussiansplatter to achieve this ?
>>>> 
>>>> Thanks in advance
>>>> 
>>>> Michka Popoff
>>>> _______________________________________________
>>>> 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
>>>> 
>> 
>> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130620/8b7b219d/attachment.htm>


More information about the vtkusers mailing list