Skip to content
/ Tr Public

A Go implementation of Ray Tracing in One Weekend by Peter Shirley

Notifications You must be signed in to change notification settings

i-am-g2/Tr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tr

A Go implementation of Ray Tracing in One Weekend Peter Shirley.

Spheres

Note: Output of the program is in .ppm format, which is not supported by many applications. See more about .ppm here

Basic

go build -o Tracer
./Tracer > outputs/image.ppm

Playing With Tracer

Edit main.go to play around and generate different renders. You may want to edit the camera parameters, add more objects (spheres) to the world or play with equations. I will be adding docs later.

Objects

Camera

cam := InitCamera(lookFrom, lookAt, vup, aspectRatio, fieldOfView , apperture, focalDist)

Parameters Description
lookFrom Vector of dim-3 describing coordinates of camera lens
lookAt Point ( i.e Vector dim-3) where camera is pointed
vup Point defining direction of up direction for camera
aspectRatio Ratio of heigt & width
fieldOfView Camera field of views in degrees
apperture Apperture of the camera lens
focalDist Focal length of camera

Materials

  • Metal

    mat := NewMetal(Albedo, fuzziness) , where Albedo is a vector of 3 dimension (r,g,b) denoting Albedo (in simpler words, color) of material and fuzziness is a float denoting fuzziness of metal's surface

  • Lambertian

    mat := NewLambertian(Albedo) , where Albedo is a vector of 3 dimension (r,g,b) denoting Albedo (in simpler words, color) of material

  • Dielectric

    Materials like glass, water etc.
    mat := NewDielectric(Ir) , where Ir denotes Refractive Index of the material

Hittable

  • Sphere

sphr := NewSphere (center, radius, Material)

Parameters Description
center 3 dimensional vector denoting the center of spehere
radius float denotes radius
material Metal, Lambertian or Dielectric

Todos / Improvements

  • Use miltiple cpu cores while tracing.
  • Add documentation
  • Add .jpg or .png support

About

A Go implementation of Ray Tracing in One Weekend by Peter Shirley

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages