pt

package
v0.0.0-...-6fa0015 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2017 License: MIT Imports: 18 Imported by: 14

Documentation

Index

Constants

View Source
const (
	ColorChannel = iota
	VarianceChannel
	StandardDeviationChannel
	SamplesChannel
)
View Source
const (
	LightModeRandom = iota
	LightModeAll
)
View Source
const (
	SpecularModeNaive = iota
	SpecularModeFirst
	SpecularModeAll
)
View Source
const (
	BounceTypeAny = iota
	BounceTypeDiffuse
	BounceTypeSpecular
)
View Source
const EPS = 1e-9
View Source
const INF = 1e9

Variables

View Source
var (
	Black = Color{}
	White = Color{1, 1, 1}
)
View Source
var NoHit = Hit{nil, INF, nil}

Functions

func Clamp

func Clamp(x, lo, hi float64) float64

func ClampInt

func ClampInt(x, lo, hi int) int

func Degrees

func Degrees(radians float64) float64

func DurationString

func DurationString(d time.Duration) string

func Fract

func Fract(x float64) float64

func LoadImage

func LoadImage(path string) (image.Image, error)

func LoadMTL

func LoadMTL(path string, parent Material, materials map[string]*Material) error

func Median

func Median(items []float64) float64

func NumberString

func NumberString(x float64) string

func ParameterTest

func ParameterTest(scene *Scene, camera *Camera, w, h int, duration time.Duration)

func ParseFloats

func ParseFloats(items []string) []float64

func ParseInts

func ParseInts(items []string) []int

func Radians

func Radians(degrees float64) float64

func RelativePath

func RelativePath(path1, path2 string) string

func SavePNG

func SavePNG(path string, im image.Image) error

func SaveSTL

func SaveSTL(path string, mesh *Mesh) error

Types

type Axis

type Axis uint8
const (
	AxisNone Axis = iota
	AxisX
	AxisY
	AxisZ
)

type BounceType

type BounceType int

type Box

type Box struct {
	Min, Max Vector
}

func BoxForShapes

func BoxForShapes(shapes []Shape) Box

func BoxForTriangles

func BoxForTriangles(shapes []*Triangle) Box

func (Box) Anchor

func (a Box) Anchor(anchor Vector) Vector

func (Box) Center

func (a Box) Center() Vector

func (Box) Contains

func (a Box) Contains(b Vector) bool

func (Box) Extend

func (a Box) Extend(b Box) Box

func (Box) InnerRadius

func (a Box) InnerRadius() float64

func (*Box) Intersect

func (b *Box) Intersect(r Ray) (float64, float64)

func (Box) Intersects

func (a Box) Intersects(b Box) bool

func (Box) OuterRadius

func (a Box) OuterRadius() float64

func (*Box) Partition

func (b *Box) Partition(axis Axis, point float64) (left, right bool)

func (Box) Size

func (a Box) Size() Vector

type Buffer

type Buffer struct {
	W, H   int
	Pixels []Pixel
}

func NewBuffer

func NewBuffer(w, h int) *Buffer

func (*Buffer) AddSample

func (b *Buffer) AddSample(x, y int, sample Color)

func (*Buffer) Color

func (b *Buffer) Color(x, y int) Color

func (*Buffer) Copy

func (b *Buffer) Copy() *Buffer

func (*Buffer) Image

func (b *Buffer) Image(channel Channel) image.Image

func (*Buffer) Samples

func (b *Buffer) Samples(x, y int) int

func (*Buffer) StandardDeviation

func (b *Buffer) StandardDeviation(x, y int) Color

func (*Buffer) Variance

func (b *Buffer) Variance(x, y int) Color

type Camera

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

func LookAt

func LookAt(eye, center, up Vector, fovy float64) Camera

func (*Camera) CastRay

func (c *Camera) CastRay(x, y, w, h int, u, v float64, rnd *rand.Rand) Ray

func (*Camera) SetFocus

func (c *Camera) SetFocus(focalPoint Vector, apertureRadius float64)

type CapsuleSDF

type CapsuleSDF struct {
	A, B     Vector
	Radius   float64
	Exponent float64
}

func (*CapsuleSDF) BoundingBox

func (s *CapsuleSDF) BoundingBox() Box

func (*CapsuleSDF) Evaluate

func (s *CapsuleSDF) Evaluate(p Vector) float64

type Channel

type Channel int

type Color

type Color struct {
	R, G, B float64
}

func HexColor

func HexColor(x int) Color

func Kelvin

func Kelvin(K float64) Color

func NewColor

func NewColor(c color.Color) Color

func (Color) Add

func (a Color) Add(b Color) Color

func (Color) DivScalar

func (a Color) DivScalar(b float64) Color

func (Color) Max

func (a Color) Max(b Color) Color

func (Color) MaxComponent

func (a Color) MaxComponent() float64

func (Color) Min

func (a Color) Min(b Color) Color

func (Color) MinComponent

func (a Color) MinComponent() float64

func (Color) Mix

func (a Color) Mix(b Color, pct float64) Color

func (Color) Mul

func (a Color) Mul(b Color) Color

func (Color) MulScalar

func (a Color) MulScalar(b float64) Color

func (Color) Pow

func (a Color) Pow(b float64) Color

func (Color) RGBA

func (a Color) RGBA() color.RGBA

func (Color) RGBA64

func (a Color) RGBA64() color.RGBA64

func (Color) Sub

func (a Color) Sub(b Color) Color

type ColorTexture

type ColorTexture struct {
	Width  int
	Height int
	Data   []Color
}

func (*ColorTexture) BumpSample

func (t *ColorTexture) BumpSample(u, v float64) Vector

func (*ColorTexture) MulScalar

func (t *ColorTexture) MulScalar(a float64) Texture

func (*ColorTexture) NormalSample

func (t *ColorTexture) NormalSample(u, v float64) Vector

func (*ColorTexture) Pow

func (t *ColorTexture) Pow(a float64) Texture

func (*ColorTexture) Sample

func (t *ColorTexture) Sample(u, v float64) Color

type Cube

type Cube struct {
	Min      Vector
	Max      Vector
	Material Material
	Box      Box
}

func NewCube

func NewCube(min, max Vector, material Material) *Cube

func (*Cube) BoundingBox

func (c *Cube) BoundingBox() Box

func (*Cube) Compile

func (c *Cube) Compile()

func (*Cube) Intersect

func (c *Cube) Intersect(r Ray) Hit

func (*Cube) MaterialAt

func (c *Cube) MaterialAt(p Vector) Material

func (*Cube) Mesh

func (c *Cube) Mesh() *Mesh

func (*Cube) NormalAt

func (c *Cube) NormalAt(p Vector) Vector

func (*Cube) UV

func (c *Cube) UV(p Vector) Vector

type CubeSDF

type CubeSDF struct {
	Size Vector
}

func (*CubeSDF) BoundingBox

func (s *CubeSDF) BoundingBox() Box

func (*CubeSDF) Evaluate

func (s *CubeSDF) Evaluate(p Vector) float64

type Cylinder

type Cylinder struct {
	Radius   float64
	Z0, Z1   float64
	Material Material
}

func NewCylinder

func NewCylinder(radius, z0, z1 float64, material Material) *Cylinder

func (*Cylinder) BoundingBox

func (c *Cylinder) BoundingBox() Box

func (*Cylinder) Compile

func (c *Cylinder) Compile()

func (*Cylinder) Intersect

func (shape *Cylinder) Intersect(ray Ray) Hit

func (*Cylinder) MaterialAt

func (c *Cylinder) MaterialAt(p Vector) Material

func (*Cylinder) NormalAt

func (c *Cylinder) NormalAt(p Vector) Vector

func (*Cylinder) UV

func (c *Cylinder) UV(p Vector) Vector

type CylinderSDF

type CylinderSDF struct {
	Radius float64
	Height float64
}

func (*CylinderSDF) BoundingBox

func (s *CylinderSDF) BoundingBox() Box

func (*CylinderSDF) Evaluate

func (s *CylinderSDF) Evaluate(p Vector) float64

type DefaultSampler

type DefaultSampler struct {
	FirstHitSamples int
	MaxBounces      int
	DirectLighting  bool
	SoftShadows     bool
	LightMode       LightMode
	SpecularMode    SpecularMode
}

func NewDirectSampler

func NewDirectSampler() *DefaultSampler

func NewSampler

func NewSampler(firstHitSamples, maxBounces int) *DefaultSampler

func (*DefaultSampler) Sample

func (s *DefaultSampler) Sample(scene *Scene, ray Ray, rnd *rand.Rand) Color

type DifferenceSDF

type DifferenceSDF struct {
	Items []SDF
}

func (*DifferenceSDF) BoundingBox

func (s *DifferenceSDF) BoundingBox() Box

func (*DifferenceSDF) Evaluate

func (s *DifferenceSDF) Evaluate(p Vector) float64

type Func

type Func func(x, y float64) float64

type Function

type Function struct {
	Function Func
	Box      Box
	Material Material
}

func (*Function) BoundingBox

func (f *Function) BoundingBox() Box

func (*Function) Compile

func (f *Function) Compile()

func (*Function) Contains

func (f *Function) Contains(v Vector) bool

func (*Function) Intersect

func (f *Function) Intersect(ray Ray) Hit

func (*Function) MaterialAt

func (f *Function) MaterialAt(p Vector) Material

func (*Function) NormalAt

func (f *Function) NormalAt(p Vector) Vector

func (*Function) UV

func (f *Function) UV(p Vector) Vector

type Hit

type Hit struct {
	Shape   Shape
	T       float64
	HitInfo *HitInfo
}

func (*Hit) Info

func (hit *Hit) Info(r Ray) HitInfo

func (*Hit) Ok

func (hit *Hit) Ok() bool

type HitInfo

type HitInfo struct {
	Shape    Shape
	Position Vector
	Normal   Vector
	Ray      Ray
	Material Material
	Inside   bool
}

type IntersectionSDF

type IntersectionSDF struct {
	Items []SDF
}

func (*IntersectionSDF) BoundingBox

func (s *IntersectionSDF) BoundingBox() Box

func (*IntersectionSDF) Evaluate

func (s *IntersectionSDF) Evaluate(p Vector) float64

type LightMode

type LightMode int

type Material

type Material struct {
	Color          Color
	Texture        Texture
	NormalTexture  Texture
	BumpTexture    Texture
	GlossTexture   Texture
	BumpMultiplier float64
	Emittance      float64
	Index          float64 // refractive index
	Gloss          float64 // reflection cone angle in radians
	Tint           float64 // specular and refractive tinting
	Reflectivity   float64 // metallic reflection
	Transparent    bool
}

func ClearMaterial

func ClearMaterial(index, gloss float64) Material

func DiffuseMaterial

func DiffuseMaterial(color Color) Material

func GlossyMaterial

func GlossyMaterial(color Color, index, gloss float64) Material

func LightMaterial

func LightMaterial(color Color, emittance float64) Material

func MaterialAt

func MaterialAt(shape Shape, point Vector) Material

func MetallicMaterial

func MetallicMaterial(color Color, gloss, tint float64) Material

func SpecularMaterial

func SpecularMaterial(color Color, index float64) Material

func TransparentMaterial

func TransparentMaterial(color Color, index, gloss, tint float64) Material

type Matrix

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

func Frustum

func Frustum(l, r, b, t, n, f float64) Matrix

func Identity

func Identity() Matrix

func LookAtMatrix

func LookAtMatrix(eye, center, up Vector) Matrix

func Orthographic

func Orthographic(l, r, b, t, n, f float64) Matrix

func Perspective

func Perspective(fovy, aspect, near, far float64) Matrix

func Rotate

func Rotate(v Vector, a float64) Matrix

func Scale

func Scale(v Vector) Matrix

func Translate

func Translate(v Vector) Matrix

func (Matrix) Determinant

func (a Matrix) Determinant() float64

func (Matrix) Frustum

func (m Matrix) Frustum(l, r, b, t, n, f float64) Matrix

func (Matrix) Inverse

func (a Matrix) Inverse() Matrix

func (Matrix) Mul

func (a Matrix) Mul(b Matrix) Matrix

func (Matrix) MulBox

func (a Matrix) MulBox(box Box) Box

func (Matrix) MulDirection

func (a Matrix) MulDirection(b Vector) Vector

func (Matrix) MulPosition

func (a Matrix) MulPosition(b Vector) Vector

func (Matrix) MulRay

func (a Matrix) MulRay(b Ray) Ray

func (Matrix) Orthographic

func (m Matrix) Orthographic(l, r, b, t, n, f float64) Matrix

func (Matrix) Perspective

func (m Matrix) Perspective(fovy, aspect, near, far float64) Matrix

func (Matrix) Rotate

func (m Matrix) Rotate(v Vector, a float64) Matrix

func (Matrix) Scale

func (m Matrix) Scale(v Vector) Matrix

func (Matrix) Translate

func (m Matrix) Translate(v Vector) Matrix

func (Matrix) Transpose

func (a Matrix) Transpose() Matrix

type Mesh

type Mesh struct {
	Triangles []*Triangle
	// contains filtered or unexported fields
}

func LoadOBJ

func LoadOBJ(path string, parent Material) (*Mesh, error)

func LoadSTL

func LoadSTL(path string, material Material) (*Mesh, error)

func NewMesh

func NewMesh(triangles []*Triangle) *Mesh

func NewSDFMesh

func NewSDFMesh(sdf SDF, box Box, step float64) *Mesh

func (*Mesh) Add

func (a *Mesh) Add(b *Mesh)

func (*Mesh) BoundingBox

func (m *Mesh) BoundingBox() Box

func (*Mesh) Compile

func (m *Mesh) Compile()

func (*Mesh) Copy

func (m *Mesh) Copy() *Mesh

func (*Mesh) FitInside

func (m *Mesh) FitInside(box Box, anchor Vector)

func (*Mesh) Intersect

func (m *Mesh) Intersect(r Ray) Hit

func (*Mesh) MaterialAt

func (m *Mesh) MaterialAt(p Vector) Material

func (*Mesh) MoveTo

func (m *Mesh) MoveTo(position, anchor Vector)

func (*Mesh) NormalAt

func (m *Mesh) NormalAt(p Vector) Vector

func (*Mesh) SaveSTL

func (m *Mesh) SaveSTL(path string) error

func (*Mesh) SetMaterial

func (m *Mesh) SetMaterial(material Material)

func (*Mesh) SmoothNormals

func (m *Mesh) SmoothNormals()

func (*Mesh) SmoothNormalsThreshold

func (m *Mesh) SmoothNormalsThreshold(radians float64)

func (*Mesh) Transform

func (m *Mesh) Transform(matrix Matrix)

func (*Mesh) UV

func (m *Mesh) UV(p Vector) Vector

func (*Mesh) UnitCube

func (m *Mesh) UnitCube()

type Node

type Node struct {
	Axis   Axis
	Point  float64
	Shapes []Shape
	Left   *Node
	Right  *Node
}

func NewNode

func NewNode(shapes []Shape) *Node

func (*Node) Intersect

func (node *Node) Intersect(r Ray, tmin, tmax float64) Hit

func (*Node) IntersectShapes

func (node *Node) IntersectShapes(r Ray) Hit

func (*Node) Partition

func (node *Node) Partition(size int, axis Axis, point float64) (left, right []Shape)

func (*Node) PartitionScore

func (node *Node) PartitionScore(axis Axis, point float64) int

func (*Node) Split

func (node *Node) Split(depth int)

type Pixel

type Pixel struct {
	Samples int
	M, V    Color
}

func (*Pixel) AddSample

func (p *Pixel) AddSample(sample Color)

func (*Pixel) Color

func (p *Pixel) Color() Color

func (*Pixel) StandardDeviation

func (p *Pixel) StandardDeviation() Color

func (*Pixel) Variance

func (p *Pixel) Variance() Color

type Plane

type Plane struct {
	Point    Vector
	Normal   Vector
	Material Material
}

func NewPlane

func NewPlane(point, normal Vector, material Material) *Plane

func (*Plane) BoundingBox

func (p *Plane) BoundingBox() Box

func (*Plane) Compile

func (p *Plane) Compile()

func (*Plane) Intersect

func (p *Plane) Intersect(ray Ray) Hit

func (*Plane) MaterialAt

func (p *Plane) MaterialAt(a Vector) Material

func (*Plane) NormalAt

func (p *Plane) NormalAt(a Vector) Vector

func (*Plane) UV

func (p *Plane) UV(a Vector) Vector

type Ray

type Ray struct {
	Origin, Direction Vector
}

func (Ray) Bounce

func (i Ray) Bounce(info *HitInfo, u, v float64, bounceType BounceType, rnd *rand.Rand) (Ray, bool, float64)

func (Ray) ConeBounce

func (r Ray) ConeBounce(theta, u, v float64, rnd *rand.Rand) Ray

func (Ray) Position

func (r Ray) Position(t float64) Vector

func (Ray) Reflect

func (n Ray) Reflect(i Ray) Ray

func (Ray) Reflectance

func (n Ray) Reflectance(i Ray, n1, n2 float64) float64

func (Ray) Refract

func (n Ray) Refract(i Ray, n1, n2 float64) Ray

func (Ray) WeightedBounce

func (r Ray) WeightedBounce(u, v float64, rnd *rand.Rand) Ray

type Renderer

type Renderer struct {
	Scene              *Scene
	Camera             *Camera
	Sampler            Sampler
	Buffer             *Buffer
	SamplesPerPixel    int
	StratifiedSampling bool
	AdaptiveSamples    int
	AdaptiveThreshold  float64
	AdaptiveExponent   float64
	FireflySamples     int
	FireflyThreshold   float64
	NumCPU             int
	Verbose            bool
}

func NewRenderer

func NewRenderer(scene *Scene, camera *Camera, sampler Sampler, w, h int) *Renderer

func (*Renderer) ChannelRender

func (r *Renderer) ChannelRender() <-chan image.Image

func (*Renderer) FrameRender

func (r *Renderer) FrameRender(path string, iterations int, wg *sync.WaitGroup)

func (*Renderer) IterativeRender

func (r *Renderer) IterativeRender(pathTemplate string, iterations int) image.Image

func (*Renderer) Render

func (r *Renderer) Render() image.Image

func (*Renderer) TimedRender

func (r *Renderer) TimedRender(duration time.Duration) image.Image

type RepeatSDF

type RepeatSDF struct {
	SDF
	Step Vector
}

func (*RepeatSDF) BoundingBox

func (s *RepeatSDF) BoundingBox() Box

func (*RepeatSDF) Evaluate

func (s *RepeatSDF) Evaluate(p Vector) float64

type SDF

type SDF interface {
	Evaluate(p Vector) float64
	BoundingBox() Box
}

func NewCapsuleSDF

func NewCapsuleSDF(a, b Vector, radius float64) SDF

func NewCubeSDF

func NewCubeSDF(size Vector) SDF

func NewCylinderSDF

func NewCylinderSDF(radius, height float64) SDF

func NewDifferenceSDF

func NewDifferenceSDF(items ...SDF) SDF

func NewIntersectionSDF

func NewIntersectionSDF(items ...SDF) SDF

func NewRepeatSDF

func NewRepeatSDF(sdf SDF, step Vector) SDF

func NewScaleSDF

func NewScaleSDF(sdf SDF, factor float64) SDF

func NewSphereSDF

func NewSphereSDF(radius float64) SDF

func NewTorusSDF

func NewTorusSDF(major, minor float64) SDF

func NewTransformSDF

func NewTransformSDF(sdf SDF, matrix Matrix) SDF

func NewUnionSDF

func NewUnionSDF(items ...SDF) SDF

type SDFShape

type SDFShape struct {
	SDF
	Material Material
}

func (*SDFShape) Compile

func (s *SDFShape) Compile()

func (*SDFShape) Intersect

func (s *SDFShape) Intersect(ray Ray) Hit

func (*SDFShape) MaterialAt

func (s *SDFShape) MaterialAt(p Vector) Material

func (*SDFShape) NormalAt

func (s *SDFShape) NormalAt(p Vector) Vector

func (*SDFShape) UV

func (s *SDFShape) UV(p Vector) Vector

type STLHeader

type STLHeader struct {
	Count uint32
	// contains filtered or unexported fields
}

type STLTriangle

type STLTriangle struct {
	N, V1, V2, V3 [3]float32
	// contains filtered or unexported fields
}

type Sampler

type Sampler interface {
	Sample(scene *Scene, ray Ray, rnd *rand.Rand) Color
}

type ScaleSDF

type ScaleSDF struct {
	SDF
	Factor float64
}

func (*ScaleSDF) BoundingBox

func (s *ScaleSDF) BoundingBox() Box

func (*ScaleSDF) Evaluate

func (s *ScaleSDF) Evaluate(p Vector) float64

type Scene

type Scene struct {
	Color        Color
	Texture      Texture
	TextureAngle float64
	Shapes       []Shape
	Lights       []Shape
	// contains filtered or unexported fields
}

func (*Scene) Add

func (s *Scene) Add(shape Shape)

func (*Scene) Compile

func (s *Scene) Compile()

func (*Scene) Intersect

func (s *Scene) Intersect(r Ray) Hit

func (*Scene) RayCount

func (s *Scene) RayCount() uint64

type Shape

type Shape interface {
	Compile()
	BoundingBox() Box
	Intersect(Ray) Hit
	UV(Vector) Vector
	NormalAt(Vector) Vector
	MaterialAt(Vector) Material
}

func NewFunction

func NewFunction(function Func, box Box, material Material) Shape

func NewSDFShape

func NewSDFShape(sdf SDF, material Material) Shape

func NewSphere

func NewSphere(center Vector, radius float64, material Material) Shape

func NewSphericalHarmonic

func NewSphericalHarmonic(l, m int, pm, nm Material) Shape

func NewTransformedCylinder

func NewTransformedCylinder(v0, v1 Vector, radius float64, material Material) Shape

func NewTransformedShape

func NewTransformedShape(s Shape, m Matrix) Shape

type SpecularMode

type SpecularMode int

type Sphere

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

func (*Sphere) BoundingBox

func (s *Sphere) BoundingBox() Box

func (*Sphere) Compile

func (s *Sphere) Compile()

func (*Sphere) Intersect

func (s *Sphere) Intersect(r Ray) Hit

func (*Sphere) MaterialAt

func (s *Sphere) MaterialAt(p Vector) Material

func (*Sphere) NormalAt

func (s *Sphere) NormalAt(p Vector) Vector

func (*Sphere) UV

func (s *Sphere) UV(p Vector) Vector

type SphereSDF

type SphereSDF struct {
	Radius   float64
	Exponent float64
}

func (*SphereSDF) BoundingBox

func (s *SphereSDF) BoundingBox() Box

func (*SphereSDF) Evaluate

func (s *SphereSDF) Evaluate(p Vector) float64

type SphericalHarmonic

type SphericalHarmonic struct {
	PositiveMaterial Material
	NegativeMaterial Material
	// contains filtered or unexported fields
}

func (*SphericalHarmonic) BoundingBox

func (s *SphericalHarmonic) BoundingBox() Box

func (*SphericalHarmonic) Compile

func (s *SphericalHarmonic) Compile()

func (*SphericalHarmonic) Evaluate

func (s *SphericalHarmonic) Evaluate(p Vector) float64

func (*SphericalHarmonic) EvaluateHarmonic

func (s *SphericalHarmonic) EvaluateHarmonic(p Vector) float64

func (*SphericalHarmonic) Intersect

func (s *SphericalHarmonic) Intersect(r Ray) Hit

func (*SphericalHarmonic) MaterialAt

func (s *SphericalHarmonic) MaterialAt(p Vector) Material

func (*SphericalHarmonic) NormalAt

func (s *SphericalHarmonic) NormalAt(p Vector) Vector

func (*SphericalHarmonic) UV

func (s *SphericalHarmonic) UV(p Vector) Vector

type Texture

type Texture interface {
	Sample(u, v float64) Color
	NormalSample(u, v float64) Vector
	BumpSample(u, v float64) Vector
	Pow(a float64) Texture
	MulScalar(a float64) Texture
}

func GetTexture

func GetTexture(path string) Texture

func LoadTexture

func LoadTexture(path string) (Texture, error)

func NewTexture

func NewTexture(im image.Image) Texture

type TorusSDF

type TorusSDF struct {
	MajorRadius   float64
	MinorRadius   float64
	MajorExponent float64
	MinorExponent float64
}

func (*TorusSDF) BoundingBox

func (s *TorusSDF) BoundingBox() Box

func (*TorusSDF) Evaluate

func (s *TorusSDF) Evaluate(p Vector) float64

type TransformSDF

type TransformSDF struct {
	SDF
	Matrix  Matrix
	Inverse Matrix
}

func (*TransformSDF) BoundingBox

func (s *TransformSDF) BoundingBox() Box

func (*TransformSDF) Evaluate

func (s *TransformSDF) Evaluate(p Vector) float64

type TransformedShape

type TransformedShape struct {
	Shape
	Matrix  Matrix
	Inverse Matrix
}

func (*TransformedShape) BoundingBox

func (s *TransformedShape) BoundingBox() Box

func (*TransformedShape) Intersect

func (s *TransformedShape) Intersect(r Ray) Hit

type Tree

type Tree struct {
	Box  Box
	Root *Node
}

func NewTree

func NewTree(shapes []Shape) *Tree

func (*Tree) Intersect

func (tree *Tree) Intersect(r Ray) Hit

type Triangle

type Triangle struct {
	Material   *Material
	V1, V2, V3 Vector
	N1, N2, N3 Vector
	T1, T2, T3 Vector
}

func NewTriangle

func NewTriangle(v1, v2, v3, t1, t2, t3 Vector, material Material) *Triangle

func (*Triangle) Area

func (t *Triangle) Area() float64

func (*Triangle) Barycentric

func (t *Triangle) Barycentric(p Vector) (u, v, w float64)

func (*Triangle) BoundingBox

func (t *Triangle) BoundingBox() Box

func (*Triangle) Compile

func (t *Triangle) Compile()

func (*Triangle) FixNormals

func (t *Triangle) FixNormals()

func (*Triangle) Intersect

func (t *Triangle) Intersect(r Ray) Hit

func (*Triangle) MaterialAt

func (t *Triangle) MaterialAt(p Vector) Material

func (*Triangle) Normal

func (t *Triangle) Normal() Vector

func (*Triangle) NormalAt

func (t *Triangle) NormalAt(p Vector) Vector

func (*Triangle) UV

func (t *Triangle) UV(p Vector) Vector

func (*Triangle) Vertices

func (t *Triangle) Vertices() (Vector, Vector, Vector)

type UnionSDF

type UnionSDF struct {
	Items []SDF
}

func (*UnionSDF) BoundingBox

func (s *UnionSDF) BoundingBox() Box

func (*UnionSDF) Evaluate

func (s *UnionSDF) Evaluate(p Vector) float64

type Vector

type Vector struct {
	X, Y, Z float64
}

func Cone

func Cone(direction Vector, theta, u, v float64, rnd *rand.Rand) Vector

func PoissonDisc

func PoissonDisc(x1, y1, x2, y2, r float64, n int) []Vector

func RandomUnitVector

func RandomUnitVector(rnd *rand.Rand) Vector

func V

func V(x, y, z float64) Vector

func (Vector) Abs

func (a Vector) Abs() Vector

func (Vector) Add

func (a Vector) Add(b Vector) Vector

func (Vector) AddScalar

func (a Vector) AddScalar(b float64) Vector

func (Vector) Cross

func (a Vector) Cross(b Vector) Vector

func (Vector) Div

func (a Vector) Div(b Vector) Vector

func (Vector) DivScalar

func (a Vector) DivScalar(b float64) Vector

func (Vector) Dot

func (a Vector) Dot(b Vector) float64

func (Vector) Length

func (a Vector) Length() float64

func (Vector) LengthN

func (a Vector) LengthN(n float64) float64

func (Vector) Max

func (a Vector) Max(b Vector) Vector

func (Vector) MaxComponent

func (a Vector) MaxComponent() float64

func (Vector) Min

func (a Vector) Min(b Vector) Vector

func (Vector) MinAxis

func (a Vector) MinAxis() Vector

func (Vector) MinComponent

func (a Vector) MinComponent() float64

func (Vector) Mod

func (a Vector) Mod(b Vector) Vector

func (Vector) Mul

func (a Vector) Mul(b Vector) Vector

func (Vector) MulScalar

func (a Vector) MulScalar(b float64) Vector

func (Vector) Negate

func (a Vector) Negate() Vector

func (Vector) Normalize

func (a Vector) Normalize() Vector

func (Vector) Reflect

func (n Vector) Reflect(i Vector) Vector

func (Vector) Reflectance

func (n Vector) Reflectance(i Vector, n1, n2 float64) float64

func (Vector) Refract

func (n Vector) Refract(i Vector, n1, n2 float64) Vector

func (Vector) Sub

func (a Vector) Sub(b Vector) Vector

func (Vector) SubScalar

func (a Vector) SubScalar(b float64) Vector

type Volume

type Volume struct {
	W, H, D int
	ZScale  float64
	Data    []float64
	Windows []VolumeWindow
	Box     Box
}

func NewVolume

func NewVolume(box Box, images []image.Image, sliceSpacing float64, windows []VolumeWindow) *Volume

func (*Volume) BoundingBox

func (v *Volume) BoundingBox() Box

func (*Volume) Compile

func (v *Volume) Compile()

func (*Volume) Get

func (v *Volume) Get(x, y, z int) float64

func (*Volume) Intersect

func (v *Volume) Intersect(ray Ray) Hit

func (*Volume) MaterialAt

func (v *Volume) MaterialAt(p Vector) Material

func (*Volume) NormalAt

func (v *Volume) NormalAt(p Vector) Vector

func (*Volume) Sample

func (v *Volume) Sample(x, y, z float64) float64

func (*Volume) Sign

func (v *Volume) Sign(a Vector) int

func (*Volume) UV

func (v *Volume) UV(p Vector) Vector

type VolumeWindow

type VolumeWindow struct {
	Lo, Hi   float64
	Material Material
}

Jump to

Keyboard shortcuts

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