Docsity

Ray Tracing through Volume: Rendering Images of 3D Densities using a Ray Casting Algorithm, Study Guides, Projects, Research of Computer Graphics

Toggle sidebar
bg1
Third project: ray tracing through volume
1 Description
This goal is to render a few images of volumetric datasets using a simple ray casting algo-
rithm. Basically, you have to set up the view, use one of the provided datasets and a set of
your own transfer functions to draw a few fun images. You will then post your images on
a web page and send us (both Andrzej and Enylton) a pointer. We do not post any view
parameters or details on how to do the rendering, just take the input files and produce fun
images.
2 Input file format
We post a few volumes, all of them are 3D arrays with entries given being 4 byte floats
(bytes come in x86 order). The dimensions of the array are encoded in the 12-byte header
(which contains three 4 byte integers, also in x86 format).
To read the files, read the header. If the integers in the header are dx, dy, dz , then the
entry of the volume at (i, j, k) is the i+dx ∗j+dx ∗dy ∗k-th float that follows the header.
3 Method
Use ray tracing-like approach: shoot rays from viewpoint through space. Think of the
dataset as a dust cloud whose thickness at a 3D point is proportional to the density (value
of the scalar field). Here is how we are going to compute the intensity for a pixel.
Shoot a ray through that pixel from the viewpoint (as in your project 1 ray tracer). We
are going to assume that at each point pof the ray, the dust cloud behaves like a semi-
transparent surface which lets through a fraction of light proportional to 1 −density(p),
(where density(p) is the density at p) comming from behind it in the direction of the
viewpoint and contributes amount of light that can be computed as density(p)∗I(p),
where I(p) is exactly the same as the illumination formula in ray tracing computed with
the normal vector being the normalized gradient of the density at p. We are going to use
only the diffuse term to compute I(p): thus, I(p) = C(p)∗max(N(p)·L(p),0), where C(p)
is the color at p(in our case, it’s going to be defined by the density function – see below).
All of the above leads to the following algorithm to compute color Cincoming from
direction d(given by a unit vector) to the viewpoint o:
C:= 0
for k := 1 to ∞do
pk:= o+k∗∆∗d
αk:= 1 −(1 −density(pk))β∗∆
t:= αk∗(1 −α)
C:= C+t∗I(pk)
α:= α+t
where βand ∆ are constants (∆ plays the role of a step size and βis an arbitrary constant).
Fortunately, the loop doesn’t really have to run to infinity, it can be aborted when 1 −α
drops below some threshold. αcan be thought of as opacity accumulating along the ray.
Color computed at the k-th sample contributes to the pixel’s color with weight t.
1
pf2

Partial preview of the text

Download Ray Tracing through Volume: Rendering Images of 3D Densities using a Ray Casting Algorithm and more Study Guides, Projects, Research Computer Graphics in PDF only on Docsity!

Third project: ray tracing through volume

1 Description

This goal is to render a few images of volumetric datasets using a simple ray casting algo- rithm. Basically, you have to set up the view, use one of the provided datasets and a set of your own transfer functions to draw a few fun images. You will then post your images on a web page and send us (both Andrzej and Enylton) a pointer. We do not post any view parameters or details on how to do the rendering, just take the input files and produce fun images.

2 Input file format

We post a few volumes, all of them are 3D arrays with entries given being 4 byte floats (bytes come in x86 order). The dimensions of the array are encoded in the 12-byte header (which contains three 4 byte integers, also in x86 format). To read the files, read the header. If the integers in the header are dx, dy, dz, then the entry of the volume at (i, j, k) is the i + dx ∗ j + dx ∗ dy ∗ k-th float that follows the header.

3 Method

Use ray tracing-like approach: shoot rays from viewpoint through space. Think of the dataset as a dust cloud whose thickness at a 3D point is proportional to the density (value of the scalar field). Here is how we are going to compute the intensity for a pixel. Shoot a ray through that pixel from the viewpoint (as in your project 1 ray tracer). We are going to assume that at each point p of the ray, the dust cloud behaves like a semi- transparent surface which lets through a fraction of light proportional to 1 − density(p), (where density(p) is the density at p) comming from behind it in the direction of the viewpoint and contributes amount of light that can be computed as density(p) ∗ I(p), where I(p) is exactly the same as the illumination formula in ray tracing computed with the normal vector being the normalized gradient of the density at p. We are going to use only the diffuse term to compute I(p): thus, I(p) = C(p) ∗ max(N (p) · L(p), 0), where C(p) is the color at p (in our case, it’s going to be defined by the density function – see below). All of the above leads to the following algorithm to compute color C incoming from direction d (given by a unit vector) to the viewpoint o:

C := 0 for k := 1 to ∞ do pk := o + k ∗ ∆ ∗ d αk := 1 − (1 − density(pk))β∗∆ t := αk ∗ (1 − α) C := C + t ∗ I(pk) α := α + t

where β and ∆ are constants (∆ plays the role of a step size and β is an arbitrary constant). Fortunately, the loop doesn’t really have to run to infinity, it can be aborted when 1 − α drops below some threshold. α can be thought of as opacity accumulating along the ray. Color computed at the k-th sample contributes to the pixel’s color with weight t.

isovalue

Figure 1: d function for rendering isosurfaces.

isovalue isovalue

Figure 2: Another d function.

4 Computing gradient

Use 3D Sobel filter (link provided).

5 Color and density

Color and density can be computed by applying some function to the input scalar field values. Basically, if f is the scalar field (which can be computed from the input data using, say, tri-linear interpolation) then Color(p) = C(f (p)) and density(p) = d(f (p)). What C and d to use? It depends, in fact by manipulating these functions you can achieve several interesting effects, like rendering isosurfaces if you use d shown in Figure 1 and (to get monochrome image) simply a constant color (e.g. white). You can also use a smoothed variant of this ‘continuous step function’ to get a better quality image. Other interesting examples might be as shown in 2: they might produce an image of two isosurfaces, one (corresponding to isovalue1) partially transparent, one looking almost opaque. One could map densities close to the first and second isovalues to different colors as well.