models

package
v0.1.1-0...-7335341 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2019 License: Unlicense Imports: 4 Imported by: 7

Documentation

Index

Constants

View Source
const (
	LambertianMaterial = "Lambertian"
	MetalMaterial      = "Metal"
	DielectricMaterial = "Dielectric"
	LightMaterial      = "Light"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseMaterial

type BaseMaterial struct {
	Albedo *Vector
	// contains filtered or unexported fields
}

func NewBaseMaterial

func NewBaseMaterial(albedo *Vector, isLight bool) *BaseMaterial

func (*BaseMaterial) IsLight

func (b *BaseMaterial) IsLight() bool

type Camera

type Camera struct {
	LowerLeftCorner, Origin *Vector
	Horizontal, Vertical    *Vector
	LensRadius              float64
	U, V, W                 *Vector
}

func NewCamera

func NewCamera(lookFrom, lookAt, vup *Vector, vfov, aspect, aperture, focus float64) *Camera

func (*Camera) RayAt

func (c *Camera) RayAt(u, v float64, rng *rand.Rand) *Ray

type CameraInput

type CameraInput struct {
	LookFrom    [3]float64
	LookAt      [3]float64
	UpVector    [3]float64
	FieldOfView float64
	AspectRatio float64
	Focus       float64
	Aperture    float64
}

type Dielectric

type Dielectric struct {
	*BaseMaterial
	RefIndex float64
}

func NewDielectric

func NewDielectric(albedo *Vector, r float64) *Dielectric

func (*Dielectric) Scatter

func (d *Dielectric) Scatter(ray *Ray, hitRecord *HitRecord, rng *rand.Rand) (bool, *Vector, *Ray)

type HitRecord

type HitRecord struct {
	T        float64
	P        *Vector
	N        *Vector
	Material Material
}

type Hitable

type Hitable interface {
	Hit(r *Ray, tmin, tmax float64) (bool, *HitRecord)
}

type HitableList

type HitableList struct {
	List []Hitable
}

func (*HitableList) AddHitable

func (hl *HitableList) AddHitable(h Hitable)

func (*HitableList) Hit

func (hl *HitableList) Hit(r *Ray, tmin, tmax float64) (bool, *HitRecord)

type ImageInput

type ImageInput struct {
	OutputFile string
	Height     int
	Width      int
	Samples    int
	Patch      [4]int
}

func (*ImageInput) GetPatch

func (i *ImageInput) GetPatch() (int, int, int, int)

type Lambertian

type Lambertian struct {
	*BaseMaterial
}

func NewLambertian

func NewLambertian(albedo *Vector) *Lambertian

func (*Lambertian) Scatter

func (l *Lambertian) Scatter(ray *Ray, hitRecord *HitRecord, rng *rand.Rand) (bool, *Vector, *Ray)

type Light

type Light struct {
	*BaseMaterial
}

func NewLight

func NewLight(albedo *Vector) *Light

func (*Light) Scatter

func (l *Light) Scatter(ray *Ray, hitRecord *HitRecord, rng *rand.Rand) (bool, *Vector, *Ray)

type Material

type Material interface {
	Scatter(*Ray, *HitRecord, *rand.Rand) (bool, *Vector, *Ray)
	IsLight() bool
}

type Metal

type Metal struct {
	*BaseMaterial
	// contains filtered or unexported fields
}

func NewMetal

func NewMetal(albedo *Vector, fuzz float64) *Metal

func (*Metal) Scatter

func (m *Metal) Scatter(ray *Ray, hitRecord *HitRecord, rng *rand.Rand) (bool, *Vector, *Ray)

type ObjectType

type ObjectType int

type ObjectsInput

type ObjectsInput struct {
	Spheres []SphereInput
}

type Pixel

type Pixel struct {
	Color [3]uint8
	I, J  int
}

type Ray

type Ray struct {
	Origin    *Vector
	Direction *Vector
}

func (*Ray) PointAtParameter

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

type Scene

type Scene struct {
	Camera       *Camera
	HitableList  *HitableList
	AmbientLight *Vector
}

type SceneInput

type SceneInput struct {
	Camera       CameraInput
	Objects      ObjectsInput
	AmbientLight [3]float64
}

type Setting

type Setting struct {
	RenderRoutines int
	RenderDepth    int
}

type Specification

type Specification struct {
	Settings Setting
	Image    ImageInput
	Scene    SceneInput
}

func (Specification) GetCamera

func (w Specification) GetCamera() *Camera

func (Specification) GetHitableList

func (w Specification) GetHitableList() *HitableList

func (Specification) GetScene

func (w Specification) GetScene() *Scene

type Sphere

type Sphere struct {
	Center   *Vector
	Radius   float64
	Material Material
}

func NewSphere

func NewSphere(x, y, z, r float64, material Material) *Sphere

func (*Sphere) Hit

func (s *Sphere) Hit(r *Ray, tmin, tmax float64) (bool, *HitRecord)

type SphereInput

type SphereInput struct {
	Center  [3]float64
	Radius  float64
	Surface SurfaceInput
}

type SurfaceInput

type SurfaceInput struct {
	Type     string
	Albedo   [3]float64
	Fuzz     float64
	RefIndex float64
}

type Vector

type Vector struct {
	// contains filtered or unexported fields
}

func NewEmptyVector

func NewEmptyVector() *Vector

func NewVector

func NewVector(x, y, z float64) *Vector

func NewVectorFromArray

func NewVectorFromArray(data [3]float64) *Vector

func RandomPointInUnitDisk

func RandomPointInUnitDisk(rng *rand.Rand) *Vector

func RandomPointInUnitSphere

func RandomPointInUnitSphere(rng *rand.Rand) *Vector

func Refract

func Refract(v, n *Vector, ni, nt float64) (bool, *Vector)

func (*Vector) AddScaledVector

func (v *Vector) AddScaledVector(v1 *Vector, t float64) *Vector

func (*Vector) AddVector

func (v *Vector) AddVector(v1 *Vector) *Vector

func (*Vector) Copy

func (v *Vector) Copy() *Vector

func (*Vector) Dot

func (v *Vector) Dot(v1 *Vector) float64

func (*Vector) Gamma2

func (v *Vector) Gamma2()

func (*Vector) Length

func (v *Vector) Length() float64

func (*Vector) MakeUnitVector

func (v *Vector) MakeUnitVector() *Vector

func (*Vector) MultiplyVector

func (v *Vector) MultiplyVector(v1 *Vector) *Vector

func (*Vector) Negate

func (v *Vector) Negate() *Vector

func (*Vector) Reflect

func (v *Vector) Reflect(n *Vector) *Vector

func (*Vector) Scale

func (v *Vector) Scale(t float64) *Vector

func (*Vector) SquaredLength

func (v *Vector) SquaredLength() float64

func (*Vector) SubtractScaledVector

func (v *Vector) SubtractScaledVector(v1 *Vector, t float64) *Vector

func (*Vector) SubtractVector

func (v *Vector) SubtractVector(v1 *Vector) *Vector

func (*Vector) ToPixel

func (v *Vector) ToPixel(i, j int) *Pixel

func (*Vector) Update

func (v *Vector) Update(x, y, z float64) *Vector

func (*Vector) VectorCrossProduct

func (v *Vector) VectorCrossProduct(v1, v2 *Vector) *Vector

func (*Vector) X

func (v *Vector) X() float64

func (*Vector) Y

func (v *Vector) Y() float64

func (*Vector) Z

func (v *Vector) Z() float64

Jump to

Keyboard shortcuts

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