raytracer

package
v0.0.0-...-e6f9244 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Clamp

func Clamp(x float64, min float64, max float64) float64

func DegreesToRadians

func DegreesToRadians(degrees float64) float64

func DielectricScatter

func DielectricScatter(rIn Ray, rec *HitRecord, attenuation *Vector, scattered *Ray, mat Material) bool

func IsotropicScatter

func IsotropicScatter(rIn Ray, rec *HitRecord, attenuation *Vector, scattered *Ray, mat Material) bool

func LambertianScatter

func LambertianScatter(rIn Ray, rec *HitRecord, attenuation *Vector, scattered *Ray, mat Material) bool

func LightScatter

func LightScatter(rIn Ray, rec *HitRecord, attenuation *Vector, scattered *Ray, mat Material) bool

func MetalScatter

func MetalScatter(rIn Ray, rec *HitRecord, attenuation *Vector, scattered *Ray, mat Material) bool

func Min

func Min(a float64, b float64) float64

func RandomFloat64

func RandomFloat64() float64

func RandomFloat64Range

func RandomFloat64Range(min float64, max float64) float64

func Reflectance

func Reflectance(cosine float64, refIdx float64) float64

func SeedRandom

func SeedRandom()

func WriteColourPPM

func WriteColourPPM(pixel Vector, samplesPerPixel int)

func WritePPMHeader

func WritePPMHeader(imageWidth int, imageHeight int)

Types

type Box

type Box struct {
	Sides []Object
	Min   Vector
	Max   Vector
}

func NewBox

func NewBox(p0 Vector, p1 Vector, mat Material) Box

type Camera

type Camera struct {
	AspectRatio     float64
	ViewportHeight  float64
	ViewportWidth   float64
	FocalLength     float64
	Origin          Vector
	Horizontal      Vector
	Vertical        Vector
	LowerLeftCorner Vector
	LensRadius      float64
	U               Vector
	V               Vector
	W               Vector
}

func NewCamera

func NewCamera(lookFrom Vector, lookAt Vector, viewUp Vector, vFov float64, aspectRatio float64, aperture float64, focusDist float64) Camera

func (Camera) GetRay

func (cam Camera) GetRay(u float64, v float64) Ray

type Colour

type Colour = Vector

type alias

func RandomColour

func RandomColour() Colour

type ConstantMedium

type ConstantMedium struct {
	Obj     Object
	Density float64
	Colour  Colour
}

type HitRecord

type HitRecord struct {
	P         Vector
	Normal    Vector
	T         float64
	FrontFace bool
	Mat       Material
}

func (*HitRecord) SetFaceNormal

func (h *HitRecord) SetFaceNormal(r Ray, outwardNormal Vector)

type Image

type Image struct {
	Img *image.RGBA
	// contains filtered or unexported fields
}

func NewImage

func NewImage(width int, height int, samplesPerPixel int) Image

func (*Image) SaveAsPng

func (img *Image) SaveAsPng(filename string)

func (*Image) WriteColour

func (img *Image) WriteColour(x int, y int, pixel Colour)

type Material

type Material struct {
	Scatter ScatterFunc
	Colour  Colour
	Fuzz    float64
	Light   bool
}

type Object

type Object interface {
	// contains filtered or unexported methods
}

type Ray

type Ray struct {
	Origin    Vector
	Direction Vector
}

func (*Ray) At

func (r *Ray) At(t float64) Vector

type RotateY

type RotateY struct {
	P        Object
	Angle    float64
	CosTheta float64
	SinTheta float64
}

func NewRotateY

func NewRotateY(p Object, angle float64) RotateY

type ScatterFunc

type ScatterFunc func(rIn Ray, rec *HitRecord, attenuation *Vector, scattered *Ray, mat Material) bool

type Scene

type Scene struct {
	Objects []Object
}

func (*Scene) AddObject

func (s *Scene) AddObject(obj Object)

func (Scene) Hit

func (s Scene) Hit(r Ray, tMin float64, tMax float64, rec *HitRecord) bool

type Sphere

type Sphere struct {
	Center Vector
	Radius float64
	Mat    Material
}

type Translate

type Translate struct {
	P      Object
	Offset Vector
}

type Vector

type Vector struct {
	X float64
	Y float64
	Z float64
}

func RandomInUnitDisk

func RandomInUnitDisk() Vector

func RandomInUnitSphere

func RandomInUnitSphere() Vector

func RandomUnitVector

func RandomUnitVector() Vector

func RandomVector

func RandomVector(min float64, max float64) Vector

func Reflect

func Reflect(v Vector, n Vector) Vector

func Refract

func Refract(uv Vector, n Vector, etaiOverEtat float64) Vector

func (Vector) Add

func (v Vector) Add(v2 Vector) Vector

func (Vector) Cross

func (v Vector) Cross(v2 Vector) Vector

func (Vector) Divide

func (v Vector) Divide(v2 Vector) Vector

func (Vector) DivideN

func (v Vector) DivideN(n float64) Vector

func (Vector) Dot

func (v Vector) Dot(v2 Vector) float64

func (Vector) Length

func (v Vector) Length() float64

func (Vector) LengthSquared

func (v Vector) LengthSquared() float64

func (Vector) Minus

func (v Vector) Minus(v2 Vector) Vector

func (Vector) MinusN

func (v Vector) MinusN(n float64) Vector

func (Vector) Multiply

func (v Vector) Multiply(v2 Vector) Vector

func (Vector) MultiplyN

func (v Vector) MultiplyN(n float64) Vector

func (Vector) NearZero

func (v Vector) NearZero() bool

func (Vector) UnitVector

func (v Vector) UnitVector() Vector

type XYRect

type XYRect struct {
	X0  float64
	X1  float64
	Y0  float64
	Y1  float64
	K   float64
	Mat Material
}

type XZRect

type XZRect struct {
	X0  float64
	X1  float64
	Z0  float64
	Z1  float64
	K   float64
	Mat Material
}

type YZRect

type YZRect struct {
	Y0  float64
	Y1  float64
	Z0  float64
	Z1  float64
	K   float64
	Mat Material
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL