《三维可视化英文PPT.ppt》由会员分享,可在线阅读,更多相关《三维可视化英文PPT.ppt(54页珍藏版)》请在三一办公上搜索。
1、Volume Renderingusing Graphics Hardware,Travis GorkinGPU Programming and Architecture,June 2009,Agenda,Volume Rendering BackgroundVolumetric DataOptical ModelAccumulation EquationsVolume Rendering on the CPURaymarching AlgorithmVolume Rendering on Graphics HardwareSlice-Based Volume RenderingStream
2、Model for Volume RaycastingVolume Rendering in CUDA,Volume Rendering Definition,Generate 2D projection of 3D data setVisualization of medical and scientific dataRendering natural effects-fluids,smoke,fireDirect Volume Rendering(DVR)Done without extracting any surface geometry,Volumetric Data,3D Data
3、 SetDiscretely sampled on regular grid in 3D space3D array of samples,Voxel volume elementOne or more constant data valuesScalars density,temperature,opacityVectors color,normal,gradientSpatial coordinates determined by position in data structureTrilinear interpolationLeverage graphics hardware,Tran
4、sfer Function,Maps voxel data values to optical propertiesGlorified color mapsEmphasize or classify features of interest in the dataPiecewise linear functions,Look-up tables,1D,2DGPU simple shader functions,texture lookup tables,Volume Rendering Optical Model,Light interacts with volume particles th
5、rough:AbsorptionEmissionScatteringSample volume along viewing raysAccumulate optical properties,Volume Ray Marching,Raycast once per pixelSample uniform intervals along rayInterpolate trilinear interpolate,apply transfer functionAccumulate integrate optical properties,Ray Marching Accumulation Equat
6、ions,Accumulation=IntegralColor,Total Color=Accumulation(Sampled Colors x Sampled Transmissivities),Transmissivity=1-Opacity,Ray Marching Accumulation Equations,Discrete VersionsAccumulation=SumColorOpacity,Transmissivity=1-Opacity,CPU Based Volume Rendering,Raycast and raymarch for each pixel in sc
7、eneCamera(eye)location:For Each PixelLook Direction:Cast Ray Along:Accumulate Color Along Line,CPU Based Volume Rendering,Sequential ProcessMinutes or Hours per frameOptimizationsSpace PartitioningEarly Ray Termination,Volumetric Shadows,Light attenuated as passes through volumeDeeper samples receiv
8、e less illuminationSecond raymarch from sample point to light sourceAccumulate illumination from samples point of viewSame accumulation equationsPrecomputed Light TransmissivityPrecalculate illumination for each voxel centerTrilinearly interpolate at render timeView independent,scene/light source de
9、pendent,GPU Based Volume Rendering,GPU Gems Volume 1:Chapter 39“Volume Rendering Techniques”Milan Ikits,Joe Kniss,Aaron Lefohn,Charles HansenIEEE Visualization 2003 Tutorial“Interactive Visualization of Volumetric Data on Consumer PC Hardware”“Acceleration Techniques for GPU-Based Volume Rendering”J
10、.Krugger and R.Westermann,IEEE Visualization 2003,Slice-Based Volume Rendering(SBVR),No volumetric primitive in graphics APIProxy geometry-polygon primitives as slices through volumeTexture polygons with volumetric dataDraw slices in sorted order back-to-frontUse fragment shader to perform compositi
11、ng(blending),Volumetric Data,Voxel data sent to GPU memory asStack of 2D textures3D textureLeverage graphics pipeline,Instructions for setting up 3D texture in OpenGLhttp:/gpwiki.org/index.php/OpenGL_3D_Textures,Proxy Geometry,Slices through 3D voxel data3D voxel data=3D texture on GPUAssign texture
12、 coordinate to every slice vertexCPU or vertex shader,Proxy Geometry,Object-Aligned SlicesFast and simpleThree stacks of 2D textures x,y,z principle directionsTexture stack swapped based on closest to viewpoint,Proxy Geometry,Issues with Object-Aligned Slices3x memory consumption Data replicated alo
13、ng 3 principle directionsChange in viewpoint results in stack swapImage popping artifactsLag while downloading new texturesSampling distance changes with viewpointIntensity variations as camera moves,Proxy Geometry,View-Aligned SlicesSlower,but more memory efficientConsistent sampling distance,Proxy
14、 Geometry,View-Aligned Slices AlgorithmIntersect slicing planes with bounding boxSort resulting vertices in(counter)clockwise orderConstruct polygon primitive from centroid as triangle fan,Proxy Geometry,Spherical ShellsBest replicates volume ray castingImpractical complex proxy geometry,Sliced-Base
15、d Volume Rendering Steps,Rendering Proxy Geometry,CompositingOver operator back-to-front orderUnder operator front-to-back order,Rendering Proxy Geometry,Compositing=Color and Alpha Accumulation EquationsEasily implemented using hardware alpha blendingOverSource=1Destination=1-Source AlphaUnderSourc
16、e=1-Destination AlphaDestination=1,Simple Volume Rendering Fragment Shader,void main(uniform float3 emissiveColor,uniform sampler3D dataTex,float3 texCoord:TEXCOORD0,float4 color:COLOR)float a=tex3D(texCoord,dataTex);/Read 3D data texture color=a*emissiveColor;/Multiply by opac,Fragment Shader with
17、Transfer Function,void main(uniform sampler3D dataTex,uniform sampler1D tfTex,float3 texCoord:TEXCOORD0,float4 color:COLOR)float v=tex3d(texCoord,dataTex);/Read 3D data color=tex1d(v,tfTex);/transfer function,Local Illumination,Blinn-Phong Shading Model,Resulting=Ambient+Diffuse+Specular,Local Illum
18、ination,Blinn-Phong Shading ModelRequires surface normal vectorWhats the normal vector of a voxel?,Resulting=Ambient+Diffuse+Specular,Local Illumination,Blinn-Phong Shading ModelRequires surface normal vectorWhats the normal vector of a voxel?GradientCentral differences between neighboring voxels,Re
19、sulting=Ambient+Diffuse+Specular,Local Illumination,Compute on-the-fly within fragment shaderRequires 6 texture fetches per calculationPrecalculate on host and store in voxel dataRequires 4x texture memoryPack into 3D RGBA texture to send to GPU,Local Illumination,Improve perception of depthAmplify
20、surface structure,Volumetric Shadows on GPU,Light attenuated from lights point of viewCPU Precomputed Light TransferSecondary raymarch from sample to light sourceGPUTwo-pass algorithmModify proxy geometry slicingRender from both the eye and the lights POVTwo different frame buffers,Two Pass Volume R
21、endering with Shadows,Slice axis set half-way between view and light directionsAllows each slice to be rendered from eye and light POVRender order for light front-to-backRender order for eye(a)front-to-back(b)back-to-front,First Pass,Render from eyeFragment shaderLook up light color from light buffe
22、r bound as textureMultiply material color*light color,Second pass,Render from lightFragment shaderOnly blend alpha values light transmissivity,Volumetric Shadows,Scattering and Translucency,General scattering effects too complex for interactive renderingTranslucency result of scatteringOnly need to
23、consider incoming light from cone in direction of light source,Scattering and Translucency,Blurring operationSee GPU Gems Chap 39 for details,Performance and Limitations,Huge amount of fragment/pixel operationsTexture accessLighting calculationBlendingLarge memory usageProxy geometry3D textures,Volu
24、me Raycasting on GPU,“Acceleration Techniques for GPU-Based Volume Rendering”Krugger and Westermann,2003Stream model taken from work in GPU RaytracingRaymarching implemented in fragment programCast rays of sight through volumeAccumulate color and opacityTerminate when opacity reaches threshold,Volum
25、e Raycasting on GPU,Multi-pass algorithmInitial passesPrecompute ray directions and lengthsAdditional passesPerform raymarching in parallel for each pixelSplit up full raymarch to check for early termination,Step 1:Ray Direction Computation,Ray direction computed for each pixelStored in 2D texture f
26、or use in later stepsPass 1:Front faces of volume bounding boxPass 2:Back faces of volume bounding boxVertex color components encode object-space principle directions,Step 1:Ray Direction Computation,Subtraction blend two texturesStore normalized direction RGB componentsStore length Alpha component,
27、Fragment Shader Raymarching,DIRxy ray direction texture2D RGBA valuesP per-vertex float3 positions,front of volume bounding boxInterpolated for fragment shader by graphics pipelines constant step sizeFloat valued total raymarched distance,s x#stepsFloat value,Fragment Shader Raymarching,DIRxy ray di
28、rection texture2D RGBA valuesP per-vertex float3 positions,front of volume bounding boxInterpolated for fragment shader by graphics pipelines constant step sizeFloat valued total raymarched distance,s x#stepsFloat valueParametric Ray Equationr 3D texture coordinates used to sample voxel data,Fragmen
29、t Shader Raymarching,Ray traversal procedure split into multiple passesM steps along ray for each passAllows for early ray termination,optimizationOptical properties accumulated along M stepsSimple compositing/blending operationsColor and alpha(opacity)Accumulation result for M steps blended into 2D
30、 result textureStores overall accumlated values between multiple passesIntermediate Pass checks for early terminationCompare opacity to thresholdCheck for ray leaving bounding volume,Optimizations,Early Ray TerminationCompare accumulated opacity against thresholdEmpty Space SkippingAdditional data s
31、tructure encoding empty space in volumeOct-treeEncode measure of empty within 3D texture read from fragment shaderRaymarching fragment shader can modulate sampling distance based on empty space value,Performance and Limitations,More physically-based than slice-based volume renderingGuarantees equal
32、sampling distancesDoes not incorporate volumetric shadowsReduced number of fragment operationsFragment programs made more complexOptimizations work best for non-opaque data setsEarly ray termination and empty space skipping can be applied,Volume Rendering in CUDA,NVIDIA CUDA SDK Code SamplesExample:
33、Basic Volume Rendering using 3D Textureshttp:/,Volume Rendering in CUDA,3D Slicer www.slicer.orgOpen source software for visualization and image analysisFunded by NIH,medical imaging,MRI dataCurrently integrating CUDA volume rendering into Slicer 3.2,Volume Rendering in CUDA,“Volume Raycasting with
34、CUDA”Jusub Kim,Ph.D.Dissertation,Univeristy of Maryland,College Park,2008http:/Stream model for raycasting implemented in CUDAEfficiently balance warps of threads and block sizesSingle instruction execution within warp of threadsAvoid memory conflicts with warps of threads,Agenda,Volume Rendering Ba
35、ckgroundVolumetric DataOptical ModelAccumulation EquationsVolume Rendering on the CPURaymarching AlgorithmVolume Rendering on Graphics HardwareSlice-Based Volume RenderingStream Model for Volume RaycastingVolume Rendering in CUDA,References,“Chapter 39.Volume Rendering Techniques”,GPU Gems Volume 1,
36、Ikits,Kniss,Lefohn,Hansen,2003http:/“Interactive Visualization of Volumetric Data on Consumer PC Hardware”IEEE Visualization 2003 Tutorialhttp:/www.vis.uni-stuttgart.de/vis03_tutorial/“Acceleration Techniques for GPU-Based Volume Rendering”J.Krugger and R.Westermann,IEEE Visualization 2003http:/wwwc
37、g.in.tum.de/Research/data/Publications/vis03-rc.pdf3D Slicer:Volume Rendering with CUDAhttp:/www.slicer.org/slicerWiki/index.php/Slicer3:Volume_Rendering_With_Cuda,References,“Volume Raycasting with Cuda”,Jusub Kim,2008http:/Volume Rendering”,Jerry Tessendorf,Slides presented at University of Pennsylvania,2008“Real-Time Volume Graphics”,SIGGRAPH 2004http:/old.vrvis.at/via/resources/course-volgraphics-2004/,