Zombiefruit / Volume_Raytracer

An application that raytraces through a volume (comprised of scanned slices), and incorporates internal reflection and refraction as well as standard DRR (Digitally Reconstructed Radiograph) attenuation. This was completed as part of a series of assignments for Computer Graphics (CMPE 454), a final-year course offered at Queen's University in Ontario, Canada

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Introduction

This assignment had us modify a fragment shader (trace.frag) to trace rays through a volume, incorporating refraction and internal reflection. The volumes were sourced from the URL given in PVMSource.txt, included in this repo.

Overview

As a brief overview, the application:

  • figures out the texture coordinate space (TCS) position and direction of the fragment in question, as well as finding that same fragment's position and direction in the world coordinate system (WCS)
  • steps through the volume, incrementing a variable to track the accumlated transparency of the volume (which will modify the final fragment colour) and computing the changing direction of a ray as the index of refraction changes for each slice of the volume stepped through
  • finally computing the exit position and direction of a ray which has travelled through the volume, which is then used to determine the fragment colour

Images

This is a volume representing a hydrogen atom and its orbitals. Here, we are just visualizing the density of the volume (press '3', and hit the '+' key to increase the density factor enough to visualize this yourself).

Hydrogen Density

This is the same volume, now with refraction and reflection (the density factor is low enough to not attenuate the colour much - it is mostly the direction of the ray that changes).

Hydrogen reflection and refraction

And here are two images of a volume representing a lens. The banding is due to the fact that the volume is a series of slices. Decreasing the spacing value improves this effect, but cannot remove it entirely.

Lens from the front

Lens from the side

Running the application

All you have to do is download the source, run "make" in the source directory, and then run "./volren <file.pvm>", where file is one of the .pvm files included (i.e. "./volren Hydrogen.pvm" will run the application with the Hydrogen volume). Pressing the '+' and '-' keys increase and decrease the density factor. The '<' and '>' keys modify the slice-spacing. Pressing '4' will visualize reflection and refraction.

Disclaimer

Our task was to modify the refractionOrReflectionDirection(), lookupBackgroundTexture(), and main() functions in the trace.frag shader. We were supplied with the other code, which was written by Professor James Stewart, at Queen's University (http://research.cs.queensu.ca/~jstewart/).

About

An application that raytraces through a volume (comprised of scanned slices), and incorporates internal reflection and refraction as well as standard DRR (Digitally Reconstructed Radiograph) attenuation. This was completed as part of a series of assignments for Computer Graphics (CMPE 454), a final-year course offered at Queen's University in Ontario, Canada


Languages

Language:C++ 82.7%Language:GLSL 14.2%Language:Makefile 2.3%Language:C 0.8%