[vtkusers] Volume rendering

Natraj Iyer iyern at ecn.purdue.edu
Thu Sep 27 14:59:57 EDT 2001


Hi,

I am having problems in volume rendering a voxelized object. The
lighting seems to be really bad. I tried adding lights but it does not
help.. Does anyone have any suggestions on how to rectify this.. When I
generate the isosurface using vtkContourFilter it works fine..

My voxel.vtk file just contains 1's and 0's.

I have to use vtkImageCast because VTK gives me an error saying Data
Type 2 is unsupported.

Thanks

Natraj

My tcl script is as follows:

vtkDataSetReader areader
   areader SetFileName voxel.vtk

vtkImageCast reader
reader SetOutputScalarTypeToUnsignedShort
reader SetInput [areader GetOutput]

# Create transfer functions for opacity and color
vtkPiecewiseFunction opacityTransferFunction
    opacityTransferFunction AddPoint  0  0.0
    opacityTransferFunction AddPoint  1  1.0

vtkColorTransferFunction colorTransferFunction
    colorTransferFunction AddRGBPoint       0.0 1.0 0.0 0.0
    colorTransferFunction AddRGBPoint      1.0 0.0 0.0 0.3

# Create properties, mappers, volume actors, and ray cast function
vtkVolumeProperty volumeProperty
    volumeProperty SetColor colorTransferFunction
    volumeProperty SetScalarOpacity opacityTransferFunction
    volumeProperty ShadeOn
    volumeProperty SetDiffuse 1.0
    volumeProperty SetAmbient 0.3
    volumeProperty SetSpecular 1.0
    volumeProperty SetSpecularPower 100.0

vtkVolumeRayCastCompositeFunction  compositeFunction

vtkVolumeRayCastMapper volumeMapper
    volumeMapper SetInput [reader GetOutput]
    volumeMapper SetVolumeRayCastFunction compositeFunction

vtkVolume volume
	volume SetMapper volumeMapper
	volume SetProperty volumeProperty

vtkLight light1
light1 SetPositional 1
light1 SetPosition 15.0 15.0 15.0

vtkLight light2
light2 SetPositional 1
light2 SetPosition -5.0 -5.0 -5.0

vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
    renWin SetSize 300 300
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin
    iren LightFollowCameraOn

ren1 AddVolume volume
ren1 SetBackground 1.0 1.0 0.9
ren1 AddLight light1
ren1 AddLight light2

renWin Render





More information about the vtkusers mailing list