go-ray-tracer

command module
Version: v0.0.0-...-1b60a0e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2019 License: MIT Imports: 17 Imported by: 0

README

go-ray-tracer GoReportCard GoDoc

A Go implementation of a 3D renderer using a ray tracing algorithm.

Milestones

I'll be adding images of renderings that I create on my journey to write a 3D renderer below.

6. Shadows

My sixth rendering is the same ray traced world as the last rendering but with shadows!

The rendering demonstrates using shadow rays to determine if a point is in a shadow or not. If a point is in shadow, the ray tracer will omit the diffuse and specular contribution and only use the ambient contribution to shade the pixel.

I also learned about shadow acne, which happens because computers cannot represent floating point numbers very precisely.

To produce the rendering, run:

git checkout 678a29ae
go run main.go

Shadow Rendering

5. Ray Traced World

My fifth rendering is a ray traced world which includes 3 spheres sitting in a room with walls.

The rendering demonstrates the implementation of a camera with a field of view and view transformation matrix. The view transformation matrix orients the camera by specifying where to look from and to, and which way is up.

I found the following to be good reads for more on view transformation matrices:

To produce the rendering, run:

git checkout 2c4b679d
go run main.go

World Rendering

4. Ray Traced Spheres in 3D

My fourth rendering is my first ever 3D rendering! Producing a 3D rendering was one of those moments that felt like magic. Those are the moments that keep me excited about programming.

The rendering demonstrates the use of the phong reflection model for pixel shading, computing normal vectors on a sphere, and vector reflection.

To produce the renderings, run:

git checkout 2a062177
go run main.go

Sphere Rendering Sphere Rendering Sphere Rendering Sphere Rendering Sphere Rendering

3. Ray Traced Spheres in 2D

My third rendering is the first one that is actually ray-traced! It's a circle that was produced by casting rays at a sphere and filling in colored pixels where an intersection occurred.

The rendering demonstrates the use of a line-sphere intersection algorithm and transformation matrices (e.g., scaling, rotation, shearing) applied to the spheres.

To produce the renderings, run:

git checkout 0f43b4d8
go run main.go

Sphere Rendering Sphere Rendering Sphere Rendering Sphere Rendering Sphere Rendering

2. Clock Rendering

My second rendering is a clock. The clock has a pixel for each hour of 1-12.

The rendering demonstrates the use of matrix transforms (e.g., translate, rotate) on points.

You may need to squint in order to see the hour locations on the clock!

To produce the rendering, run:

git checkout db9f301c
go run main.go

Projectile Rendering

1. Projectile Rendering

My very first rendering is a projectile with a starting point, initial velocity, wind, and gravity.

The rendering demonstrates the use of points and vectors.

To produce the rendering, run:

git checkout 7c481890
go run main.go

Projectile Rendering

Documentation

The Go Gopher

There is no documentation for this package.

Source Files

Directories

Path Synopsis
Package camera provides a virtual camera that allows for taking pictures of a scene.
Package camera provides a virtual camera that allows for taking pictures of a scene.
Package canvas represents a rectangular grid of Pixels.
Package canvas represents a rectangular grid of Pixels.
Package color represents ranges of red, green, and blue in the range of [0, 1].
Package color represents ranges of red, green, and blue in the range of [0, 1].
Package light provides light sources and shading.
Package light provides light sources and shading.
Package material represents a material on the surface of an object.
Package material represents a material on the surface of an object.
Package maths contains math utility functions.
Package maths contains math utility functions.
Package matrix represents a matrix of a given dimension.
Package matrix represents a matrix of a given dimension.
Package point represents a point in a left-handed 3D coordinate system.
Package point represents a point in a left-handed 3D coordinate system.
Package ray represents a ray, or line, which has an origin and direction.
Package ray represents a ray, or line, which has an origin and direction.
Package sphere represents a sphere object with an origin and radius.
Package sphere represents a sphere object with an origin and radius.
Package vector represents a vector in a left-handed 3D coordinate system.
Package vector represents a vector in a left-handed 3D coordinate system.
Package world represents a collection of all Objects that make up a scene.
Package world represents a collection of all Objects that make up a scene.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL