Docsity

Isosurface Rendering: Creating 3D Images with Shaded Isosurfaces, Study Guides, Projects, Research of Computer Graphics

Toggle sidebar
bg1
Project 5 - Isosurface rendering
In this project, you’ll be rendering shaded isosurface images. Isosurfaces are
like the contours on a map except for they are 3D surfaces rather than lines.
Contours consist of points on the same height in a terrain. Isosurfaces consist
of points that have the same density (intensity) in a 3D image. Here, by a 3D
image we mean a 3D array of ‘3D pixels’ (called voxels). Sometimes, contours
or isosurfaces are called level sets since they consist of points on the same ‘level’.
Isosurfaces are used for many purposes, one of them being visualization of
medical images such as Computed Tomography (CT) or Magnetic Resonance
Imaging (MRI) scans. Although triangle mesh models of isosurfaces can be
computed explicitly and just rendered as 3D surfaces, one can do without that
to get isosurface images. In this project, you’ll implement a simple isosurface
renderer using 3D texturing and programmable shading.
1 Algorithm
The algorithm you’ll be implementing basically draws a family of parallel squares
perpendicular to the viewing direction.
viewpoint
viewing direction
(0,0,1)
(0,1,1)
(1,1,1) (1,1,0)
(0,1,0)
(1,0,0)
(0,0,0)
(0,0,2/8)
(0,0,7/8) (0,0,1/8)
(1,1,4/8)
The squares are going to be textured using the 3D texture we will provide
(basically, some kind of a medical 3D image). The texture coordinates are going
to be designed so that the planes will actually be consecutive slices through the
image. For example, initial texture coordinates assuming there are 9 slices are
show in the figure above.
Of course, if you just render the planes as you used to do in the previous
projects, you’ll just see the first one on the screen. Fortunately, they are tricks
you can use to get something more interesting.
The first one is rejecting fragments based on their properties. Rejecting a
fragment means that it does not influence the frame buffer (in particular, color
or depth of the corresponding pixel). Rejecting a fragment is very simple: you
just say ‘discard’ in the fragment shader. Of course, discard will normally
appear in a conditional statement.
1
pf3
pf4

Partial preview of the text

Download Isosurface Rendering: Creating 3D Images with Shaded Isosurfaces and more Study Guides, Projects, Research Computer Graphics in PDF only on Docsity!

Project 5 - Isosurface rendering

In this project, you’ll be rendering shaded isosurface images. Isosurfaces are like the contours on a map except for they are 3D surfaces rather than lines. Contours consist of points on the same height in a terrain. Isosurfaces consist of points that have the same density (intensity) in a 3D image. Here, by a 3D image we mean a 3D array of ‘3D pixels’ (called voxels). Sometimes, contours or isosurfaces are called level sets since they consist of points on the same ‘level’. Isosurfaces are used for many purposes, one of them being visualization of medical images such as Computed Tomography (CT) or Magnetic Resonance Imaging (MRI) scans. Although triangle mesh models of isosurfaces can be computed explicitly and just rendered as 3D surfaces, one can do without that to get isosurface images. In this project, you’ll implement a simple isosurface renderer using 3D texturing and programmable shading.

1 Algorithm

The algorithm you’ll be implementing basically draws a family of parallel squares perpendicular to the viewing direction.

viewpoint

viewing direction

(0,0,1)

(0,1,1)

(1,1,1) (1,1,0)

(0,1,0)

(1,0,0)

(0,0,0)

(0,0,7/8) (0,0,2/8)(0,0,1/8)

(1,1,4/8)

The squares are going to be textured using the 3D texture we will provide (basically, some kind of a medical 3D image). The texture coordinates are going to be designed so that the planes will actually be consecutive slices through the image. For example, initial texture coordinates assuming there are 9 slices are show in the figure above. Of course, if you just render the planes as you used to do in the previous projects, you’ll just see the first one on the screen. Fortunately, they are tricks you can use to get something more interesting. The first one is rejecting fragments based on their properties. Rejecting a fragment means that it does not influence the frame buffer (in particular, color or depth of the corresponding pixel). Rejecting a fragment is very simple: you just say ‘discard’ in the fragment shader. Of course, discard will normally appear in a conditional statement.

Let’s say that you discard fragments darker than some constant (called the isovalue) c. What you are going to see on your screen is now more interesting. Basically, all points on the squares with intensity less than c are not drawn, so you’ll be seeing an outline of the volume consisting of points with intensity above c. This means that what you actually will actually be seeing the surface formed by points with intensity exactly c (this is the boundary of that volume!). Now, all we need to do is to do some reasonable shading to add 3D look to the isosurface. One can do that by just using the usual illumination formula. But what normal should one use? Well, the normal to the isosurface, that can be computed as the gradient of the intensity (look up ‘gradient’ and ‘level set’ in wikipedia.org if you don’t remember your calculus). To simplify things, we’ll execute the illumination formula for every fragment (even for fragments that are not visible). This may be slow on poor graphics cards.

2 Requirements

2.1 Interface

When we start your code, we would like to see a nice image of the shaded isosurface. You can use 0.1 as the initial isovalue. Start with number of squares equal to 128. We need to be able to see rotating isosurface. You can either cut and paste code from your 3D viewer, allowing the user to use trackball interface to rotate the textured model or just rotate the model in an aperiodic fashion (as in the OpenGL sample code provided for project 2). Note that rotating is easiest to implement as rotating the texture coordinates. Don’t change the modelview matrix or the projection matrix when rotating. To simplify things, you can just put the light at a fixed place at infinity (hardcode its location in the fragment shader). Place the light so that the isosurface appears lit from a direction behind-above-to the right of the viewer and it looks cool. Use a combination of diffuse and ambient light for shading (for example, with 0.2 as ambient coefficient and 0.8 as diffuse coefficient). Here is the mouse menu we’d like to have available:

Faster animate faster (say, about 30% faster); don’t include this option if you use trackball interface

Slower animate slower (again, about 30%); don’t include this option if you use trackball interface

Stop/Run toggle between animation and stationary image. The default should be no animation: when we start your programs, the displayed model should be stationary; don’t include this option if you use trackball in- terface

Zoom in zoom in

getting the fragment rejection right. Basically, reject if one of the fragment’s texture coordinates are less than 0 or greater than 1 or the intensity of the fragment is less than the isovalue c. For fragments that are not rejected, set color to white You should start seeing the outline of the isosurface (without any shading yet) for reasonable isovalues. Now, add shading to your fragment shader code. Compute the gradient using finite difference approximation. Basically, if f (s, t, p) is the intensity looked up from texture coordinates (s, t, p) then compute the unnormalized gradient as

[f (s+h, t, p)−f (s−h, t, p), f (s, t+h, p)−f (s, t−h, p), f (s, t, p+h)−f (s, t, p−h)].

Normalize it and you’ll have the normal vector for the isosurface. You may want to negate it to get the normal pointing to the outside of the isosurface though. Once you are done, you can work on rotation code (which is equivalent to designing a suitable texture matrix). Make sure that the entire volume is visible during rotation (this may require scaling texture coordinates if they are to be as in the Figure). Finally, work on the keyboard-based manipulation of the isovalue. The most elegant way to do this is probably by passing the isovalue to the shader (see link).

5 Compiling and running your code on the lab

machines

This project is much simpler with a reasonable implementation of OpenGL version 2.0 and with the GLEW library installed. If you have an old graphics card or have problems installing GLEW, you should plan on finishing the shader related part in the lab. Move there as soon as you make sure that your texturing and square drawing works fine. In the lab, you will need to add /usr/local/glew-1.3.4/lib to your LD LIBRARY PATH environment variable. You can do that by using bash as your shell (if you are using a different shell, type ’bash’) and executing export LD LIBRARY PATH=$LD LIBRARY PATH:/usr/local/glew-1.3.4/lib before running your executable (once per terminal window and tab should suffice).

6 Grading

50 per cent for correct outline of the isosurface; 50 per cent for shading.