Thanks, Alark.<br><br>I tried your methods and found a better one as below.<br><br>&nbsp;&nbsp;&nbsp; tfun AddSegment 0 0.0 0.01 0.0<br>&nbsp;&nbsp;&nbsp; tfun AddSegment 0.2 1.0 255 1.0<br><br>This time, I got a gray sphere. I don't know why there are no colors as shown on the other one. Anyone knows why?
<br><br>Jian Wu<br><br><div><span class="gmail_quote">On 8/23/06, <b class="gmail_sendername">Alark Joshi</b> &lt;<a href="mailto:alark_j@hotmail.com">alark_j@hotmail.com</a>&gt; wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div>



<div>The transfer function in your case is set to 1 for all values of density in the volume. That is most probably causing the 'dark cube'. <br>
&nbsp;<br>
Try something like <br>
&nbsp;<br>
&nbsp;&nbsp;&nbsp; tfun AddSegment 0 0.0 55&nbsp;0.2<br>&nbsp;&nbsp;&nbsp; tfun AddSegment&nbsp;55&nbsp;0.2 255 1.0<br><br>
or even <br>
&nbsp;&nbsp;&nbsp; tfun AddSegment 0 0.0 255 1.0<br><br>
Hope that helps.<br>
&nbsp;<br>
Alark<br>
<br><br><br>&nbsp;<br>
<blockquote style="border-left: 2px solid rgb(0, 128, 128); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
<hr>
Date: Wed, 23 Aug 2006 13:43:19 -0400<br>From: <a href="mailto:eewujian@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">eewujian@gmail.com</a><br>To: <a href="mailto:vtkusers@vtk.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
vtkusers@vtk.org</a><br>Subject: [vtkusers] seeking for help on volume rendering<br><br>Hi, everyone,<br>I'm a new VTK user. I was failed to produced the similar results for a sample code I came upon with in the book &quot;The VTK User's Guide (
VTK4.4)&quot;. Page 122. Here is the code that I used. I made a few modification 'cause it is incomplete and has a few obvious errors for the original one. It is supposed to display two similar spheres. But I found the one given by ray-casting was incorrect. It displayed as a dark cube. Is there anyone know the reason? Thanks! 
<br><br>Jian Wu<br><br>######################################################################<br>package require vtk<br>package require vtkinteraction<br><br># Create the standard renderer, render window<br># and interactor 
<br>vtkRenderer ren1<br>vtkRenderWindow renWin<br>&nbsp;&nbsp;&nbsp; renWin AddRenderer ren1<br>vtkRenderWindowInteractor iren<br>&nbsp;&nbsp;&nbsp; iren SetRenderWindow renWin<br><br># Create a geometric sphere<br>vtkSphereSource sphere<br>&nbsp;&nbsp;&nbsp; sphere SetRadius 20 
<br>&nbsp;&nbsp;&nbsp; sphere SetCenter 70 25 25<br>&nbsp;&nbsp;&nbsp; sphere SetThetaResolution 50<br>&nbsp;&nbsp;&nbsp; sphere SetPhiResolution 50<br><br>vtkPolyDataMapper mapper<br>&nbsp;&nbsp;&nbsp; mapper SetInput [sphere GetOutput]<br><br>vtkActor actor<br>&nbsp;&nbsp;&nbsp; actor SetMapper mapper 
<br>&nbsp;&nbsp;&nbsp; [actor GetProperty] SetColor 1 1 1<br>&nbsp;&nbsp;&nbsp; [actor GetProperty] SetAmbient 0.01<br>&nbsp;&nbsp;&nbsp; [actor GetProperty] SetDiffuse 0.7<br>&nbsp;&nbsp;&nbsp; [actor GetProperty] SetSpecular 0.5<br>&nbsp;&nbsp;&nbsp; [actor GetProperty] SetSpecularPower 70.0<br>
<br># Read in a volumetric sphere<br>vtkSLCReader reader<br>&nbsp;&nbsp;&nbsp; reader SetFileName &quot;$VTK_DATA_ROOT/Data/sphere.slc&quot;<br><br># Use this tfun for both opacity and color<br>vtkPiecewiseFunction tfun<br>&nbsp;&nbsp;&nbsp; tfun AddSegment 0 
1.0 255 1.0<br><br># Make the volume property match the geometric one<br>vtkVolumeProperty volumeProperty<br>&nbsp;&nbsp;&nbsp; volumeProperty SetColor tfun<br>&nbsp;&nbsp;&nbsp; volumeProperty SetScalarOpacity tfun<br>&nbsp;&nbsp;&nbsp; volumeProperty ShadeOn<br>&nbsp;&nbsp;&nbsp; volumeProperty SetInterpolationTypeToLinear 
<br>&nbsp;&nbsp;&nbsp; volumeProperty SetDiffuse 0.7<br>&nbsp;&nbsp;&nbsp; volumeProperty SetAmbient 0.01<br>&nbsp;&nbsp;&nbsp; volumeProperty SetSpecular 0.5<br>&nbsp;&nbsp;&nbsp; volumeProperty SetSpecularPower 70.0<br><br>vtkVolumeRayCastCompositeFunction&nbsp; compositeFunction<br>
vtkVolumeRayCastMapper volumeMapper<br>&nbsp;&nbsp;&nbsp; volumeMapper SetInputConnection [reader GetOutputPort]<br>&nbsp;&nbsp;&nbsp; volumeMapper SetVolumeRayCastFunction compositeFunction<br><br>vtkVolume volume<br>&nbsp;&nbsp;&nbsp; volume SetMapper volumeMapper 
<br>&nbsp;&nbsp;&nbsp; volume SetProperty volumeProperty<br><br># Add both the geometric and volumetric spheres to the renderer<br>ren1 AddViewProp volume<br>ren1 AddViewProp actor<br><br># Create a red, green, and blue light<br>vtkLight redlight 
<br>&nbsp;&nbsp;&nbsp; redlight SetColor 1 0 0<br>&nbsp;&nbsp;&nbsp; redlight SetPosition 1000 25 25<br>&nbsp;&nbsp;&nbsp; redlight SetFocalPoint 25 25 25<br>&nbsp;&nbsp;&nbsp; redlight SetIntensity 0.5<br><br>vtkLight greenlight<br>&nbsp;&nbsp;&nbsp; greenlight SetColor 0 1 0<br>&nbsp;&nbsp;&nbsp; greenlight SetPosition 25 1000 25 
<br>&nbsp;&nbsp;&nbsp; greenlight SetFocalPoint 25 25 25<br>&nbsp;&nbsp;&nbsp; greenlight SetIntensity 0.5<br><br>vtkLight bluelight<br>&nbsp;&nbsp;&nbsp; bluelight SetColor 0 0 1<br>&nbsp;&nbsp;&nbsp; bluelight SetPosition 25 25 1000<br>&nbsp;&nbsp;&nbsp; bluelight SetFocalPoint 25 25 25<br>&nbsp;&nbsp;&nbsp; bluelight SetIntensity 
0.5<br><br># Add the light to the renderer<br>ren1 AddLight redlight<br>ren1 AddLight greenlight<br>ren1 AddLight bluelight<br>ren1 SetBackground 0.1 0.1 0.2<br><br># Render it!<br>renWin Render<br><br>proc TkCheckAbort {} { 
<br>&nbsp; set foo [renWin GetEventPending]<br>&nbsp; if {$foo != 0} {renWin SetAbortRender 1}<br>}<br>renWin AddObserver AbortCheckEvent {TkCheckAbort}<br><br>iren AddObserver UserEvent {wm deiconify .vtkInteract}<br>iren Initialize 
<br><br>wm withdraw .<br><br>######################################################################<br></blockquote></div>

</div></blockquote></div><br>