mikeswoods / ndray

A raytracer written in Haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is this is

This project is a continuation of a final project originally submitted for CIS 552: Advanced Programming at the University of Pennsylvania.

What is this is not

It is a simple raytracer and definitely NOT physically based in any way, shape or form (although this may change in the future). It was (and is) a learning experience and an excuse to play around with Haskell and computer graphics (as if one needs an excuse!).

TODO

  • Cubic texture mapping support

  • Sky sphere support -- right now, only static backgrounds are supported

  • Textures should be made more extensible so that defining new textures does not mean adding another constructor to the BasicTexture data type. I envision having a BasicTexture type, ImageTexture type, NoiseTexture type, etc. and that there is a uniform way to retrieve a texel from each given a (u,v) coordinate. I can't figure out how to do this yet with just typeclasses -- need to look into type/data families, etc.

  • Create some kind of mesh rendering options data type to control how meshes are rendered: enable/disable Phong shading, autoscaling, etc.

  • Create or find a decent Perlin/Simplex noise implementation

  • More procedural texture types: sinusoidal, noise-based, as well as more exotic ones like marble, wood, etc.

  • Allow the Lua script to modify objects in-place. So instead of, say rotating a sphere like "sphere = RotateX(sphere, 30)", you could just do "RotateX(sphere, 30)". Maybe this is a good/bad idea? Need to think about it more.

  • Split out KD-Tree implementation into a standalone package and submit to Hackage. Maybe do the same for the Tensor module as well?

Various notes

Affine Transformations
How to transform an object in an object's intersection test function

Given a 4x4 transformation matrix M:

  1. Transform the intersection point with M

  2. Transform the ray's origin and direction with inverse(M)

  3. Transform the normal at the point of intersection with transpose(inverse(M))

Refractive indices for various materials

Taken from http://en.wikipedia.org/wiki/List_of_refractive_indices

  • Vacuum n = 1.00
  • Water: n = 1.31
  • Glass: n = 1.49
  • Diamond: n = 2.419

Resources I found useful

Below is a short list of resources I found online that have helped me along the way.

Bounding boxes
AABBs (axis-aligned bounding boxes)
Algorithm overview
Affine transformations
Camera orientation
Haskell-related
Unboxing vectors, etc.
Using the ST monad (needed for JuicyPixels)
Lenses
Matrix / REPA stuff
Lua intergration with HsLua
Math
Linear algebra
Interpolation

Data structures

KD-Trees
OBJ models
Format
Example models
Intersection formulas
Plane
Sphere
Triangle
Lighting
Shading
Attenuation

http://www.cs.cmu.edu/~jkh/462_s07/assts/assignment3/

Reflection
Refraction
UV Mapping / texture mapping
Other resources
General
Textures

About

A raytracer written in Haskell

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 100.0%