Térfogatvizualizáció
description
Transcript of Térfogatvizualizáció
TérfogatvizualizációTérfogatvizualizáció
Szirmay-Kalos László
Térfogati modellekTérfogati modellek
v(x,y,z)
hőmérsékletsűrűséglégnyomáspotenciálanyagfeszültség...
v(x,y,z)
tárolás: 3D tömb
Térfogati modell megjelenítéseTérfogati modell megjelenítése
Kocka megjelenítése ??? Megjelenítés átlátszó anyagként (belsejébe
belelátunk) Adott szintfelület kiemelése (külsôt
lehámozzuk)
Átlátszó anyagokÁtlátszó anyagok
L(s + ds) L(s)
dL(s)/ds = - kt · L(s) + ka · Le + f(‘,) Li(‘) d ‘
L(s + s) L(s)
L(s + s) = L(s) - kt s · L(s) + Li(s) s
C(s)(s)
Fényemittáló, fényelnyelő anyagFényemittáló, fényelnyelő anyag
Számítás fénysugárkövetésselSzámítás fénysugárkövetéssel
L = 0for(s = 0; s < T; s += s) {
L = (1- (s)) · L + C(s)}
L(s)
L(s + s) = (1- (s)) · L(s) + C(s)
Számítás láthatóság Számítás láthatóság sugárkövetésselsugárkövetéssel
L* = 0for( s = T; s >0 ; s -= s ) {
L += (1- ) · C(s) (1- ) · ((s))if (break
}
L*(s)
(s) L*(s-s)=L*(s)+(1- (s)) · C(s)(s-s)=((s)) · ((s))
Térfogat vetítésTérfogat vetítés
L(s)
L(s + s) = (1- (s)) · L(s) + C(s)
Voxel szín és opacitás: Voxel szín és opacitás: Transfer functionsTransfer functions
Röntgen: – opacitás = v(x,y,z)– C(0) = 1, egyébként 0
Klasszikus árnyalási modellek– opacitás: v osztályozása– C = árnyalási modell (diffúz + Phong)
normál = grad v opacitás *= | grad v |
Különböző árnyalási modellek, Különböző árnyalási modellek, szegmentálásszegmentálás
Phong árnyalásPhong árnyalás
Maximum intenzitás vetítésMaximum intenzitás vetítés
Marching cubesMarching cubes
v(x,y,z) < szint
v(x,y,z) > szint
Masírozó kockákMasírozó kockák
Szintérték = 110 Szintérték = 60
Isosurface ray castingIsosurface ray casting
v(x,y,z) > isovalue
normal = grad v
GPU ray-castingGPU ray-casting
Unit cube with 3D texture
eyelookat
rightup
p = lookat + right + up
, are in [-1,1]
pqentry
exit
Isosurface ray-castingIsosurface ray-casting
For each pixel Find pixel center p raydir = normalize(p – eye); Find exit and entry for(t = entry; t < exit; t+=dt) { q = eye + raydir * t;
if (volume[q] > isovalue) break; } normal vector estimation; illumination}
Full screen quadInterpolation from the corners
central differences
Render a cubeand store the imagein a texture
GPU GPU Isosurface ray-castingIsosurface ray-casting
CPU program
Vertex shader
Pixelshader
Verticesof thewindow quad
hpos=fullscreentextcoords
volume, entry, exit texture idseye, isolevel, material/light properties
RasterizationInterpolation
volumeentrytexexittex
Interpolatedtextcoords
Ray casting
CPU program - OpenGL displayCPU program - OpenGL displayvoid Display( ) { cgGLSetParameter3f(eye, 10, 20, 30); cgGLSetParameter3f(lookat, 3, 5, 6); cgGLSetParameter3f(right, Right.x, Right.y, Right.z); cgGLSetParameter3f(up, Up.x, Up.y, Up.z);
// PASS: non uniform parameters glBegin( GL_QUADS ); Vector p = lookat - Right + Up; glTexCoord2f(0, 0); glVertex3f(p.x, p.y, p.z)
p = lookat - Right - Up; glTexCoord2f(0, 1); glVertex3f(p.x, p.y, p.z)
p = lookat + Right - Up; glTexCoord2f(1, 1); glVertex3f(p.x, p.y, p.z)
p = lookat + Right + Up; glTexCoord2f(1, 0); glVertex3f(p.x, p.y, p.z) glEnd();}
Ray castingRay casting: vertex: vertex shadershader
void VertexShader( in float3 position : POSITION, in float2 uv : TEXCOORD0,
out float4 hPosition : POSITION, out float2 ouv : TEXCOORD0, out float3 p : TEXCOORD1 ) {
hPosition = float4(uv.x * 2 – 1, 1 – uv.y * 2, 0, 1); ouv = uv; p = position;}
Ray castingRay casting: : fragment shaderfragment shadervoid FragmentShader( in float3 uv : TEXCOORD0,
in float3 p : TEXCOORD1, uniform float3 eye, uniform sampler2D entrytex, exittex,
uniform sampler3D volume, uniform float isolevel, uniform float3 lightdir, lightint, kd
) : COLOR{ float entry = tex2d(entrytex, uv); float exit = tex2d(exittex, uv); float raydir = normalize(p – eye); float dt = (exit – entry) / STEPS; bool found = false; float3 q; for(t = entry; t < exit; t += dt) { if ( !found ) {
q = eye + raydir * t; if (tex3D(volume, q).r > isolevel) found = true;}
}
Ray castingRay casting fragment shader cont’dfragment shader cont’d
float3 color = float3(0, 0, 0); // background color if ( found ) { float3 normal;
normal.x = tex3d(volume, q + float3(1/RES,0,0)) – tex3d(volume, q - float3(1/RES,0,0));
normal.y = tex3d(volume, q + float3(0,1/RES,0)) – tex3d(volume, q - float3(0,1/RES,0));
normal.z = tex3d(volume, q + float3(0,0,1/RES)) – tex3d(volume, q - float3(0,0,1/RES)); normal = normalize( normal );
color = lightint * saturate(dot(lightdir, normal)); } return float4(color, 1);}
VideoVideo