Skip to content

austingebauer/go-ray-tracer

Repository files navigation

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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published