[vtkusers] Draw points with gaussian fade out

Markus Neuner neuner.markus at gmx.net
Wed Jun 19 13:57:42 EDT 2013


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
>>>
>
>



More information about the vtkusers mailing list