pt: github.com/fogleman/pt/pt Index | Files

package pt

import "github.com/fogleman/pt/pt"

Index

Package Files

axis.go box.go buffer.go camera.go color.go common.go cube.go cylinder.go function.go hit.go material.go matrix.go mc.go mesh.go obj.go parameters.go plane.go poisson.go ray.go renderer.go sampler.go scene.go sdf.go sh.go shape.go sphere.go stl.go texture.go tree.go triangle.go util.go vector.go volume.go

Constants

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

Variables

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

func Clamp Uses

func Clamp(x, lo, hi float64) float64

func ClampInt Uses

func ClampInt(x, lo, hi int) int

func Degrees Uses

func Degrees(radians float64) float64

func DurationString Uses

func DurationString(d time.Duration) string

func Fract Uses

func Fract(x float64) float64

func LoadImage Uses

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

func LoadMTL Uses

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

func Median Uses

func Median(items []float64) float64

func NumberString Uses

func NumberString(x float64) string

func ParameterTest Uses

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

func ParseFloats Uses

func ParseFloats(items []string) []float64

func ParseInts Uses

func ParseInts(items []string) []int

func PoissonDisc Uses

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

func Radians Uses

func Radians(degrees float64) float64

func RelativePath Uses

func RelativePath(path1, path2 string) string

func SavePNG Uses

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

func SaveSTL Uses

func SaveSTL(path string, mesh *Mesh) error

type Axis Uses

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

type BounceType Uses

type BounceType int

type Box Uses

type Box struct {
    Min, Max Vector
}

func BoxForShapes Uses

func BoxForShapes(shapes []Shape) Box

func BoxForTriangles Uses

func BoxForTriangles(shapes []*Triangle) Box

func (Box) Anchor Uses

func (a Box) Anchor(anchor Vector) Vector

func (Box) Center Uses

func (a Box) Center() Vector

func (Box) Contains Uses

func (a Box) Contains(b Vector) bool

func (Box) Extend Uses

func (a Box) Extend(b Box) Box

func (Box) InnerRadius Uses

func (a Box) InnerRadius() float64

func (*Box) Intersect Uses

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

func (Box) Intersects Uses

func (a Box) Intersects(b Box) bool

func (Box) OuterRadius Uses

func (a Box) OuterRadius() float64

func (*Box) Partition Uses

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

func (Box) Size Uses

func (a Box) Size() Vector

type Buffer Uses

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

func NewBuffer Uses

func NewBuffer(w, h int) *Buffer

func (*Buffer) AddSample Uses

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

func (*Buffer) Color Uses

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

func (*Buffer) Copy Uses

func (b *Buffer) Copy() *Buffer

func (*Buffer) Image Uses

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

func (*Buffer) Samples Uses

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

func (*Buffer) StandardDeviation Uses

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

func (*Buffer) Variance Uses

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

type Camera Uses

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

func LookAt Uses

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

func (*Camera) CastRay Uses

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

func (*Camera) SetFocus Uses

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

type CapsuleSDF Uses

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

func (*CapsuleSDF) BoundingBox Uses

func (s *CapsuleSDF) BoundingBox() Box

func (*CapsuleSDF) Evaluate Uses

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

type Channel Uses

type Channel int

type Color Uses

type Color struct {
    R, G, B float64
}

func HexColor Uses

func HexColor(x int) Color

func Kelvin Uses

func Kelvin(K float64) Color

func NewColor Uses

func NewColor(c color.Color) Color

func (Color) Add Uses

func (a Color) Add(b Color) Color

func (Color) DivScalar Uses

func (a Color) DivScalar(b float64) Color

func (Color) Max Uses

func (a Color) Max(b Color) Color

func (Color) MaxComponent Uses

func (a Color) MaxComponent() float64

func (Color) Min Uses

func (a Color) Min(b Color) Color

func (Color) MinComponent Uses

func (a Color) MinComponent() float64

func (Color) Mix Uses

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

func (Color) Mul Uses

func (a Color) Mul(b Color) Color

func (Color) MulScalar Uses

func (a Color) MulScalar(b float64) Color

func (Color) Pow Uses

func (a Color) Pow(b float64) Color

func (Color) RGBA Uses

func (a Color) RGBA() color.RGBA

func (Color) RGBA64 Uses

func (a Color) RGBA64() color.RGBA64

func (Color) Sub Uses

func (a Color) Sub(b Color) Color

type ColorTexture Uses

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

func (*ColorTexture) BumpSample Uses

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

func (*ColorTexture) MulScalar Uses

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

func (*ColorTexture) NormalSample Uses

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

func (*ColorTexture) Pow Uses

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

func (*ColorTexture) Sample Uses

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

type Cube Uses

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

func NewCube Uses

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

func (*Cube) BoundingBox Uses

func (c *Cube) BoundingBox() Box

func (*Cube) Compile Uses

func (c *Cube) Compile()

func (*Cube) Intersect Uses

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

func (*Cube) MaterialAt Uses

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

func (*Cube) Mesh Uses

func (c *Cube) Mesh() *Mesh

func (*Cube) NormalAt Uses

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

func (*Cube) UV Uses

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

type CubeSDF Uses

type CubeSDF struct {
    Size Vector
}

func (*CubeSDF) BoundingBox Uses

func (s *CubeSDF) BoundingBox() Box

func (*CubeSDF) Evaluate Uses

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

type Cylinder Uses

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

func NewCylinder Uses

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

func (*Cylinder) BoundingBox Uses

func (c *Cylinder) BoundingBox() Box

func (*Cylinder) Compile Uses

func (c *Cylinder) Compile()

func (*Cylinder) Intersect Uses

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

func (*Cylinder) MaterialAt Uses

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

func (*Cylinder) NormalAt Uses

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

func (*Cylinder) UV Uses

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

type CylinderSDF Uses

type CylinderSDF struct {
    Radius float64
    Height float64
}

func (*CylinderSDF) BoundingBox Uses

func (s *CylinderSDF) BoundingBox() Box

func (*CylinderSDF) Evaluate Uses

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

type DefaultSampler Uses

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

func NewDirectSampler Uses

func NewDirectSampler() *DefaultSampler

func NewSampler Uses

func NewSampler(firstHitSamples, maxBounces int) *DefaultSampler

func (*DefaultSampler) Sample Uses

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

type DifferenceSDF Uses

type DifferenceSDF struct {
    Items []SDF
}

func (*DifferenceSDF) BoundingBox Uses

func (s *DifferenceSDF) BoundingBox() Box

func (*DifferenceSDF) Evaluate Uses

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

type Func Uses

type Func func(x, y float64) float64

type Function Uses

type Function struct {
    Function Func
    Box      Box
    Material Material
}

func (*Function) BoundingBox Uses

func (f *Function) BoundingBox() Box

func (*Function) Compile Uses

func (f *Function) Compile()

func (*Function) Contains Uses

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

func (*Function) Intersect Uses

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

func (*Function) MaterialAt Uses

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

func (*Function) NormalAt Uses

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

func (*Function) UV Uses

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

type Hit Uses

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

func (*Hit) Info Uses

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

func (*Hit) Ok Uses

func (hit *Hit) Ok() bool

type HitInfo Uses

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

type IntersectionSDF Uses

type IntersectionSDF struct {
    Items []SDF
}

func (*IntersectionSDF) BoundingBox Uses

func (s *IntersectionSDF) BoundingBox() Box

func (*IntersectionSDF) Evaluate Uses

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

type LightMode Uses

type LightMode int

type Material Uses

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 Uses

func ClearMaterial(index, gloss float64) Material

func DiffuseMaterial Uses

func DiffuseMaterial(color Color) Material

func GlossyMaterial Uses

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

func LightMaterial Uses

func LightMaterial(color Color, emittance float64) Material

func MaterialAt Uses

func MaterialAt(shape Shape, point Vector) Material

func MetallicMaterial Uses

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

func SpecularMaterial Uses

func SpecularMaterial(color Color, index float64) Material

func TransparentMaterial Uses

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

type Matrix Uses

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

func Frustum Uses

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

func Identity Uses

func Identity() Matrix

func LookAtMatrix Uses

func LookAtMatrix(eye, center, up Vector) Matrix

func Orthographic Uses

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

func Perspective Uses

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

func Rotate Uses

func Rotate(v Vector, a float64) Matrix

func Scale Uses

func Scale(v Vector) Matrix

func Translate Uses

func Translate(v Vector) Matrix

func (Matrix) Determinant Uses

func (a Matrix) Determinant() float64

func (Matrix) Frustum Uses

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

func (Matrix) Inverse Uses

func (a Matrix) Inverse() Matrix

func (Matrix) Mul Uses

func (a Matrix) Mul(b Matrix) Matrix

func (Matrix) MulBox Uses

func (a Matrix) MulBox(box Box) Box

func (Matrix) MulDirection Uses

func (a Matrix) MulDirection(b Vector) Vector

func (Matrix) MulPosition Uses

func (a Matrix) MulPosition(b Vector) Vector

func (Matrix) MulRay Uses

func (a Matrix) MulRay(b Ray) Ray

func (Matrix) Orthographic Uses

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

func (Matrix) Perspective Uses

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

func (Matrix) Rotate Uses

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

func (Matrix) Scale Uses

func (m Matrix) Scale(v Vector) Matrix

func (Matrix) Translate Uses

func (m Matrix) Translate(v Vector) Matrix

func (Matrix) Transpose Uses

func (a Matrix) Transpose() Matrix

type Mesh Uses

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

func LoadOBJ Uses

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

func LoadSTL Uses

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

func NewMesh Uses

func NewMesh(triangles []*Triangle) *Mesh

func NewSDFMesh Uses

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

func (*Mesh) Add Uses

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

func (*Mesh) BoundingBox Uses

func (m *Mesh) BoundingBox() Box

func (*Mesh) Compile Uses

func (m *Mesh) Compile()

func (*Mesh) Copy Uses

func (m *Mesh) Copy() *Mesh

func (*Mesh) FitInside Uses

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

func (*Mesh) Intersect Uses

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

func (*Mesh) MaterialAt Uses

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

func (*Mesh) MoveTo Uses

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

func (*Mesh) NormalAt Uses

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

func (*Mesh) SaveSTL Uses

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

func (*Mesh) SetMaterial Uses

func (m *Mesh) SetMaterial(material Material)

func (*Mesh) SmoothNormals Uses

func (m *Mesh) SmoothNormals()

func (*Mesh) SmoothNormalsThreshold Uses

func (m *Mesh) SmoothNormalsThreshold(radians float64)

func (*Mesh) Transform Uses

func (m *Mesh) Transform(matrix Matrix)

func (*Mesh) UV Uses

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

func (*Mesh) UnitCube Uses

func (m *Mesh) UnitCube()

type Node Uses

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

func NewNode Uses

func NewNode(shapes []Shape) *Node

func (*Node) Intersect Uses

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

func (*Node) IntersectShapes Uses

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

func (*Node) Partition Uses

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

func (*Node) PartitionScore Uses

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

func (*Node) Split Uses

func (node *Node) Split(depth int)

type Pixel Uses

type Pixel struct {
    Samples int
    M, V    Color
}

func (*Pixel) AddSample Uses

func (p *Pixel) AddSample(sample Color)

func (*Pixel) Color Uses

func (p *Pixel) Color() Color

func (*Pixel) StandardDeviation Uses

func (p *Pixel) StandardDeviation() Color

func (*Pixel) Variance Uses

func (p *Pixel) Variance() Color

type Plane Uses

type Plane struct {
    Point    Vector
    Normal   Vector
    Material Material
}

func NewPlane Uses

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

func (*Plane) BoundingBox Uses

func (p *Plane) BoundingBox() Box

func (*Plane) Compile Uses

func (p *Plane) Compile()

func (*Plane) Intersect Uses

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

func (*Plane) MaterialAt Uses

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

func (*Plane) NormalAt Uses

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

func (*Plane) UV Uses

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

type Ray Uses

type Ray struct {
    Origin, Direction Vector
}

func (Ray) Bounce Uses

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

func (Ray) ConeBounce Uses

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

func (Ray) Position Uses

func (r Ray) Position(t float64) Vector

func (Ray) Reflect Uses

func (n Ray) Reflect(i Ray) Ray

func (Ray) Reflectance Uses

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

func (Ray) Refract Uses

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

func (Ray) WeightedBounce Uses

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

type Renderer Uses

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 Uses

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

func (*Renderer) ChannelRender Uses

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

func (*Renderer) FrameRender Uses

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

func (*Renderer) IterativeRender Uses

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

func (*Renderer) Render Uses

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

func (*Renderer) TimedRender Uses

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

type RepeatSDF Uses

type RepeatSDF struct {
    SDF
    Step Vector
}

func (*RepeatSDF) BoundingBox Uses

func (s *RepeatSDF) BoundingBox() Box

func (*RepeatSDF) Evaluate Uses

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

type SDF Uses

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

func NewCapsuleSDF Uses

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

func NewCubeSDF Uses

func NewCubeSDF(size Vector) SDF

func NewCylinderSDF Uses

func NewCylinderSDF(radius, height float64) SDF

func NewDifferenceSDF Uses

func NewDifferenceSDF(items ...SDF) SDF

func NewIntersectionSDF Uses

func NewIntersectionSDF(items ...SDF) SDF

func NewRepeatSDF Uses

func NewRepeatSDF(sdf SDF, step Vector) SDF

func NewScaleSDF Uses

func NewScaleSDF(sdf SDF, factor float64) SDF

func NewSphereSDF Uses

func NewSphereSDF(radius float64) SDF

func NewTorusSDF Uses

func NewTorusSDF(major, minor float64) SDF

func NewTransformSDF Uses

func NewTransformSDF(sdf SDF, matrix Matrix) SDF

func NewUnionSDF Uses

func NewUnionSDF(items ...SDF) SDF

type SDFShape Uses

type SDFShape struct {
    SDF
    Material Material
}

func (*SDFShape) Compile Uses

func (s *SDFShape) Compile()

func (*SDFShape) Intersect Uses

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

func (*SDFShape) MaterialAt Uses

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

func (*SDFShape) NormalAt Uses

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

func (*SDFShape) UV Uses

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

type STLHeader Uses

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

type STLTriangle Uses

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

type Sampler Uses

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

type ScaleSDF Uses

type ScaleSDF struct {
    SDF
    Factor float64
}

func (*ScaleSDF) BoundingBox Uses

func (s *ScaleSDF) BoundingBox() Box

func (*ScaleSDF) Evaluate Uses

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

type Scene Uses

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

func (*Scene) Add Uses

func (s *Scene) Add(shape Shape)

func (*Scene) Compile Uses

func (s *Scene) Compile()

func (*Scene) Intersect Uses

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

func (*Scene) RayCount Uses

func (s *Scene) RayCount() uint64

type Shape Uses

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

func NewFunction Uses

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

func NewSDFShape Uses

func NewSDFShape(sdf SDF, material Material) Shape

func NewSphere Uses

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

func NewSphericalHarmonic Uses

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

func NewTransformedCylinder Uses

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

func NewTransformedShape Uses

func NewTransformedShape(s Shape, m Matrix) Shape

type SpecularMode Uses

type SpecularMode int

type Sphere Uses

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

func (*Sphere) BoundingBox Uses

func (s *Sphere) BoundingBox() Box

func (*Sphere) Compile Uses

func (s *Sphere) Compile()

func (*Sphere) Intersect Uses

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

func (*Sphere) MaterialAt Uses

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

func (*Sphere) NormalAt Uses

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

func (*Sphere) UV Uses

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

type SphereSDF Uses

type SphereSDF struct {
    Radius   float64
    Exponent float64
}

func (*SphereSDF) BoundingBox Uses

func (s *SphereSDF) BoundingBox() Box

func (*SphereSDF) Evaluate Uses

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

type SphericalHarmonic Uses

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

func (*SphericalHarmonic) BoundingBox Uses

func (s *SphericalHarmonic) BoundingBox() Box

func (*SphericalHarmonic) Compile Uses

func (s *SphericalHarmonic) Compile()

func (*SphericalHarmonic) Evaluate Uses

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

func (*SphericalHarmonic) EvaluateHarmonic Uses

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

func (*SphericalHarmonic) Intersect Uses

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

func (*SphericalHarmonic) MaterialAt Uses

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

func (*SphericalHarmonic) NormalAt Uses

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

func (*SphericalHarmonic) UV Uses

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

type Texture Uses

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 Uses

func GetTexture(path string) Texture

func LoadTexture Uses

func LoadTexture(path string) (Texture, error)

func NewTexture Uses

func NewTexture(im image.Image) Texture

type TorusSDF Uses

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

func (*TorusSDF) BoundingBox Uses

func (s *TorusSDF) BoundingBox() Box

func (*TorusSDF) Evaluate Uses

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

type TransformSDF Uses

type TransformSDF struct {
    SDF
    Matrix  Matrix
    Inverse Matrix
}

func (*TransformSDF) BoundingBox Uses

func (s *TransformSDF) BoundingBox() Box

func (*TransformSDF) Evaluate Uses

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

type TransformedShape Uses

type TransformedShape struct {
    Shape
    Matrix  Matrix
    Inverse Matrix
}

func (*TransformedShape) BoundingBox Uses

func (s *TransformedShape) BoundingBox() Box

func (*TransformedShape) Intersect Uses

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

type Tree Uses

type Tree struct {
    Box  Box
    Root *Node
}

func NewTree Uses

func NewTree(shapes []Shape) *Tree

func (*Tree) Intersect Uses

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

type Triangle Uses

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

func NewTriangle Uses

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

func (*Triangle) Area Uses

func (t *Triangle) Area() float64

func (*Triangle) Barycentric Uses

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

func (*Triangle) BoundingBox Uses

func (t *Triangle) BoundingBox() Box

func (*Triangle) Compile Uses

func (t *Triangle) Compile()

func (*Triangle) FixNormals Uses

func (t *Triangle) FixNormals()

func (*Triangle) Intersect Uses

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

func (*Triangle) MaterialAt Uses

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

func (*Triangle) Normal Uses

func (t *Triangle) Normal() Vector

func (*Triangle) NormalAt Uses

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

func (*Triangle) UV Uses

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

func (*Triangle) Vertices Uses

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

type UnionSDF Uses

type UnionSDF struct {
    Items []SDF
}

func (*UnionSDF) BoundingBox Uses

func (s *UnionSDF) BoundingBox() Box

func (*UnionSDF) Evaluate Uses

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

type Vector Uses

type Vector struct {
    X, Y, Z float64
}

func Cone Uses

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

func RandomUnitVector Uses

func RandomUnitVector(rnd *rand.Rand) Vector

func V Uses

func V(x, y, z float64) Vector

func (Vector) Abs Uses

func (a Vector) Abs() Vector

func (Vector) Add Uses

func (a Vector) Add(b Vector) Vector

func (Vector) AddScalar Uses

func (a Vector) AddScalar(b float64) Vector

func (Vector) Cross Uses

func (a Vector) Cross(b Vector) Vector

func (Vector) Div Uses

func (a Vector) Div(b Vector) Vector

func (Vector) DivScalar Uses

func (a Vector) DivScalar(b float64) Vector

func (Vector) Dot Uses

func (a Vector) Dot(b Vector) float64

func (Vector) Length Uses

func (a Vector) Length() float64

func (Vector) LengthN Uses

func (a Vector) LengthN(n float64) float64

func (Vector) Max Uses

func (a Vector) Max(b Vector) Vector

func (Vector) MaxComponent Uses

func (a Vector) MaxComponent() float64

func (Vector) Min Uses

func (a Vector) Min(b Vector) Vector

func (Vector) MinAxis Uses

func (a Vector) MinAxis() Vector

func (Vector) MinComponent Uses

func (a Vector) MinComponent() float64

func (Vector) Mod Uses

func (a Vector) Mod(b Vector) Vector

func (Vector) Mul Uses

func (a Vector) Mul(b Vector) Vector

func (Vector) MulScalar Uses

func (a Vector) MulScalar(b float64) Vector

func (Vector) Negate Uses

func (a Vector) Negate() Vector

func (Vector) Normalize Uses

func (a Vector) Normalize() Vector

func (Vector) Reflect Uses

func (n Vector) Reflect(i Vector) Vector

func (Vector) Reflectance Uses

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

func (Vector) Refract Uses

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

func (Vector) Sub Uses

func (a Vector) Sub(b Vector) Vector

func (Vector) SubScalar Uses

func (a Vector) SubScalar(b float64) Vector

type Volume Uses

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

func NewVolume Uses

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

func (*Volume) BoundingBox Uses

func (v *Volume) BoundingBox() Box

func (*Volume) Compile Uses

func (v *Volume) Compile()

func (*Volume) Get Uses

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

func (*Volume) Intersect Uses

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

func (*Volume) MaterialAt Uses

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

func (*Volume) NormalAt Uses

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

func (*Volume) Sample Uses

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

func (*Volume) Sign Uses

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

func (*Volume) UV Uses

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

type VolumeWindow Uses

type VolumeWindow struct {
    Lo, Hi   float64
    Material Material
}

Package pt imports 18 packages (graph) and is imported by 5 packages. Updated 2017-12-04. Refresh now. Tools for package owners.