Documentation ¶
Index ¶
- Constants
- Variables
- func Clamp(x, lo, hi float64) float64
- func ClampInt(x, lo, hi int) int
- func Degrees(radians float64) float64
- func DurationString(d time.Duration) string
- func Fract(x float64) float64
- func LoadImage(path string) (image.Image, error)
- func LoadMTL(path string, parent Material, materials map[string]*Material) error
- func Median(items []float64) float64
- func NumberString(x float64) string
- func ParameterTest(scene *Scene, camera *Camera, w, h int, duration time.Duration)
- func ParseFloats(items []string) []float64
- func ParseInts(items []string) []int
- func Radians(degrees float64) float64
- func RelativePath(path1, path2 string) string
- func SavePNG(path string, im image.Image) error
- func SaveSTL(path string, mesh *Mesh) error
- type Axis
- type BounceType
- type Box
- func (a Box) Anchor(anchor Vector) Vector
- func (a Box) Center() Vector
- func (a Box) Contains(b Vector) bool
- func (a Box) Extend(b Box) Box
- func (a Box) InnerRadius() float64
- func (b *Box) Intersect(r Ray) (float64, float64)
- func (a Box) Intersects(b Box) bool
- func (a Box) OuterRadius() float64
- func (b *Box) Partition(axis Axis, point float64) (left, right bool)
- func (a Box) Size() Vector
- type Buffer
- func (b *Buffer) AddSample(x, y int, sample Color)
- func (b *Buffer) Color(x, y int) Color
- func (b *Buffer) Copy() *Buffer
- func (b *Buffer) Image(channel Channel) image.Image
- func (b *Buffer) Samples(x, y int) int
- func (b *Buffer) StandardDeviation(x, y int) Color
- func (b *Buffer) Variance(x, y int) Color
- type Camera
- type CapsuleSDF
- type Channel
- type Color
- func (a Color) Add(b Color) Color
- func (a Color) DivScalar(b float64) Color
- func (a Color) Max(b Color) Color
- func (a Color) MaxComponent() float64
- func (a Color) Min(b Color) Color
- func (a Color) MinComponent() float64
- func (a Color) Mix(b Color, pct float64) Color
- func (a Color) Mul(b Color) Color
- func (a Color) MulScalar(b float64) Color
- func (a Color) Pow(b float64) Color
- func (a Color) RGBA() color.RGBA
- func (a Color) RGBA64() color.RGBA64
- func (a Color) Sub(b Color) Color
- type ColorTexture
- type Cube
- type CubeSDF
- type Cylinder
- type CylinderSDF
- type DefaultSampler
- type DifferenceSDF
- type Func
- type Function
- type Hit
- type HitInfo
- type IntersectionSDF
- type LightMode
- type Material
- func ClearMaterial(index, gloss float64) Material
- func DiffuseMaterial(color Color) Material
- func GlossyMaterial(color Color, index, gloss float64) Material
- func LightMaterial(color Color, emittance float64) Material
- func MaterialAt(shape Shape, point Vector) Material
- func MetallicMaterial(color Color, gloss, tint float64) Material
- func SpecularMaterial(color Color, index float64) Material
- func TransparentMaterial(color Color, index, gloss, tint float64) Material
- type Matrix
- func Frustum(l, r, b, t, n, f float64) Matrix
- func Identity() Matrix
- func LookAtMatrix(eye, center, up Vector) Matrix
- func Orthographic(l, r, b, t, n, f float64) Matrix
- func Perspective(fovy, aspect, near, far float64) Matrix
- func Rotate(v Vector, a float64) Matrix
- func Scale(v Vector) Matrix
- func Translate(v Vector) Matrix
- func (a Matrix) Determinant() float64
- func (m Matrix) Frustum(l, r, b, t, n, f float64) Matrix
- func (a Matrix) Inverse() Matrix
- func (a Matrix) Mul(b Matrix) Matrix
- func (a Matrix) MulBox(box Box) Box
- func (a Matrix) MulDirection(b Vector) Vector
- func (a Matrix) MulPosition(b Vector) Vector
- func (a Matrix) MulRay(b Ray) Ray
- func (m Matrix) Orthographic(l, r, b, t, n, f float64) Matrix
- func (m Matrix) Perspective(fovy, aspect, near, far float64) Matrix
- func (m Matrix) Rotate(v Vector, a float64) Matrix
- func (m Matrix) Scale(v Vector) Matrix
- func (m Matrix) Translate(v Vector) Matrix
- func (a Matrix) Transpose() Matrix
- type Mesh
- func (a *Mesh) Add(b *Mesh)
- func (m *Mesh) BoundingBox() Box
- func (m *Mesh) Compile()
- func (m *Mesh) Copy() *Mesh
- func (m *Mesh) FitInside(box Box, anchor Vector)
- func (m *Mesh) Intersect(r Ray) Hit
- func (m *Mesh) MaterialAt(p Vector) Material
- func (m *Mesh) MoveTo(position, anchor Vector)
- func (m *Mesh) NormalAt(p Vector) Vector
- func (m *Mesh) SaveSTL(path string) error
- func (m *Mesh) SetMaterial(material Material)
- func (m *Mesh) SmoothNormals()
- func (m *Mesh) SmoothNormalsThreshold(radians float64)
- func (m *Mesh) Transform(matrix Matrix)
- func (m *Mesh) UV(p Vector) Vector
- func (m *Mesh) UnitCube()
- type Node
- type Pixel
- type Plane
- type Ray
- func (i Ray) Bounce(info *HitInfo, u, v float64, bounceType BounceType, rnd *rand.Rand) (Ray, bool, float64)
- func (r Ray) ConeBounce(theta, u, v float64, rnd *rand.Rand) Ray
- func (r Ray) Position(t float64) Vector
- func (n Ray) Reflect(i Ray) Ray
- func (n Ray) Reflectance(i Ray, n1, n2 float64) float64
- func (n Ray) Refract(i Ray, n1, n2 float64) Ray
- func (r Ray) WeightedBounce(u, v float64, rnd *rand.Rand) Ray
- type Renderer
- func (r *Renderer) ChannelRender() <-chan image.Image
- func (r *Renderer) FrameRender(path string, iterations int, wg *sync.WaitGroup)
- func (r *Renderer) IterativeRender(pathTemplate string, iterations int) image.Image
- func (r *Renderer) Render() image.Image
- func (r *Renderer) TimedRender(duration time.Duration) image.Image
- type RepeatSDF
- type SDF
- func NewCapsuleSDF(a, b Vector, radius float64) SDF
- func NewCubeSDF(size Vector) SDF
- func NewCylinderSDF(radius, height float64) SDF
- func NewDifferenceSDF(items ...SDF) SDF
- func NewIntersectionSDF(items ...SDF) SDF
- func NewRepeatSDF(sdf SDF, step Vector) SDF
- func NewScaleSDF(sdf SDF, factor float64) SDF
- func NewSphereSDF(radius float64) SDF
- func NewTorusSDF(major, minor float64) SDF
- func NewTransformSDF(sdf SDF, matrix Matrix) SDF
- func NewUnionSDF(items ...SDF) SDF
- type SDFShape
- type STLHeader
- type STLTriangle
- type Sampler
- type ScaleSDF
- type Scene
- type Shape
- func NewFunction(function Func, box Box, material Material) Shape
- func NewSDFShape(sdf SDF, material Material) Shape
- func NewSphere(center Vector, radius float64, material Material) Shape
- func NewSphericalHarmonic(l, m int, pm, nm Material) Shape
- func NewTransformedCylinder(v0, v1 Vector, radius float64, material Material) Shape
- func NewTransformedShape(s Shape, m Matrix) Shape
- type SpecularMode
- type Sphere
- type SphereSDF
- type SphericalHarmonic
- func (s *SphericalHarmonic) BoundingBox() Box
- func (s *SphericalHarmonic) Compile()
- func (s *SphericalHarmonic) Evaluate(p Vector) float64
- func (s *SphericalHarmonic) EvaluateHarmonic(p Vector) float64
- func (s *SphericalHarmonic) Intersect(r Ray) Hit
- func (s *SphericalHarmonic) MaterialAt(p Vector) Material
- func (s *SphericalHarmonic) NormalAt(p Vector) Vector
- func (s *SphericalHarmonic) UV(p Vector) Vector
- type Texture
- type TorusSDF
- type TransformSDF
- type TransformedShape
- type Tree
- type Triangle
- func (t *Triangle) Area() float64
- func (t *Triangle) Barycentric(p Vector) (u, v, w float64)
- func (t *Triangle) BoundingBox() Box
- func (t *Triangle) Compile()
- func (t *Triangle) FixNormals()
- func (t *Triangle) Intersect(r Ray) Hit
- func (t *Triangle) MaterialAt(p Vector) Material
- func (t *Triangle) Normal() Vector
- func (t *Triangle) NormalAt(p Vector) Vector
- func (t *Triangle) UV(p Vector) Vector
- func (t *Triangle) Vertices() (Vector, Vector, Vector)
- type UnionSDF
- type Vector
- func (a Vector) Abs() Vector
- func (a Vector) Add(b Vector) Vector
- func (a Vector) AddScalar(b float64) Vector
- func (a Vector) Cross(b Vector) Vector
- func (a Vector) Div(b Vector) Vector
- func (a Vector) DivScalar(b float64) Vector
- func (a Vector) Dot(b Vector) float64
- func (a Vector) Length() float64
- func (a Vector) LengthN(n float64) float64
- func (a Vector) Max(b Vector) Vector
- func (a Vector) MaxComponent() float64
- func (a Vector) Min(b Vector) Vector
- func (a Vector) MinAxis() Vector
- func (a Vector) MinComponent() float64
- func (a Vector) Mod(b Vector) Vector
- func (a Vector) Mul(b Vector) Vector
- func (a Vector) MulScalar(b float64) Vector
- func (a Vector) Negate() Vector
- func (a Vector) Normalize() Vector
- func (n Vector) Reflect(i Vector) Vector
- func (n Vector) Reflectance(i Vector, n1, n2 float64) float64
- func (n Vector) Refract(i Vector, n1, n2 float64) Vector
- func (a Vector) Sub(b Vector) Vector
- func (a Vector) SubScalar(b float64) Vector
- type Volume
- func (v *Volume) BoundingBox() Box
- func (v *Volume) Compile()
- func (v *Volume) Get(x, y, z int) float64
- func (v *Volume) Intersect(ray Ray) Hit
- func (v *Volume) MaterialAt(p Vector) Material
- func (v *Volume) NormalAt(p Vector) Vector
- func (v *Volume) Sample(x, y, z float64) float64
- func (v *Volume) Sign(a Vector) int
- func (v *Volume) UV(p Vector) Vector
- type VolumeWindow
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 DurationString ¶
func NumberString ¶
func ParameterTest ¶
func ParseFloats ¶
func RelativePath ¶
Types ¶
type BounceType ¶
type BounceType int
type Box ¶
type Box struct {
Min, Max Vector
}
func BoxForShapes ¶
func BoxForTriangles ¶
func (Box) InnerRadius ¶
func (Box) Intersects ¶
func (Box) OuterRadius ¶
type Buffer ¶
func (*Buffer) StandardDeviation ¶
type CapsuleSDF ¶
func (*CapsuleSDF) BoundingBox ¶
func (s *CapsuleSDF) BoundingBox() Box
func (*CapsuleSDF) Evaluate ¶
func (s *CapsuleSDF) Evaluate(p Vector) float64
type Color ¶
type Color struct {
R, G, B float64
}
func (Color) MaxComponent ¶
func (Color) MinComponent ¶
type ColorTexture ¶
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 CylinderSDF ¶
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
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 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 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 DiffuseMaterial ¶
func GlossyMaterial ¶
func LightMaterial ¶
func MaterialAt ¶
func MetallicMaterial ¶
func SpecularMaterial ¶
func TransparentMaterial ¶
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
func LookAtMatrix ¶
func Orthographic ¶
func Perspective ¶
func (Matrix) Determinant ¶
func (Matrix) MulDirection ¶
func (Matrix) MulPosition ¶
func (Matrix) Orthographic ¶
func (Matrix) Perspective ¶
type Mesh ¶
type Mesh struct { Triangles []*Triangle // contains filtered or unexported fields }
func (*Mesh) BoundingBox ¶
func (*Mesh) MaterialAt ¶
func (*Mesh) SetMaterial ¶
func (*Mesh) SmoothNormals ¶
func (m *Mesh) SmoothNormals()
func (*Mesh) SmoothNormalsThreshold ¶
type Pixel ¶
func (*Pixel) StandardDeviation ¶
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 (*Renderer) ChannelRender ¶
func (*Renderer) FrameRender ¶
func (*Renderer) IterativeRender ¶
type RepeatSDF ¶
func (*RepeatSDF) BoundingBox ¶
type SDF ¶
func NewCapsuleSDF ¶
func NewCubeSDF ¶
func NewCylinderSDF ¶
func NewDifferenceSDF ¶
func NewIntersectionSDF ¶
func NewRepeatSDF ¶
func NewScaleSDF ¶
func NewSphereSDF ¶
func NewTorusSDF ¶
func NewTransformSDF ¶
func NewUnionSDF ¶
type SDFShape ¶
func (*SDFShape) MaterialAt ¶
type STLTriangle ¶
type STLTriangle struct {
N, V1, V2, V3 [3]float32
// contains filtered or unexported fields
}
type ScaleSDF ¶
func (*ScaleSDF) BoundingBox ¶
type Scene ¶
type Shape ¶
type Shape interface { Compile() BoundingBox() Box Intersect(Ray) Hit UV(Vector) Vector NormalAt(Vector) Vector MaterialAt(Vector) Material }
func NewSDFShape ¶
func NewSphericalHarmonic ¶
func NewTransformedCylinder ¶
func NewTransformedShape ¶
type SpecularMode ¶
type SpecularMode int
type SphereSDF ¶
func (*SphereSDF) BoundingBox ¶
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 LoadTexture ¶
func NewTexture ¶
type TorusSDF ¶
type TorusSDF struct { MajorRadius float64 MinorRadius float64 MajorExponent float64 MinorExponent float64 }
func (*TorusSDF) BoundingBox ¶
type TransformSDF ¶
func (*TransformSDF) BoundingBox ¶
func (s *TransformSDF) BoundingBox() Box
func (*TransformSDF) Evaluate ¶
func (s *TransformSDF) Evaluate(p Vector) float64
type TransformedShape ¶
func (*TransformedShape) BoundingBox ¶
func (s *TransformedShape) BoundingBox() Box
func (*TransformedShape) Intersect ¶
func (s *TransformedShape) Intersect(r Ray) Hit
type Triangle ¶
func NewTriangle ¶
func (*Triangle) Barycentric ¶
func (*Triangle) BoundingBox ¶
func (*Triangle) FixNormals ¶
func (t *Triangle) FixNormals()
func (*Triangle) MaterialAt ¶
type Vector ¶
type Vector struct {
X, Y, Z float64
}
func PoissonDisc ¶
func RandomUnitVector ¶
func (Vector) MaxComponent ¶
func (Vector) MinComponent ¶
type Volume ¶
type Volume struct {
W, H, D int
ZScale float64
Data []float64
Windows []VolumeWindow
Box Box
}
func (*Volume) BoundingBox ¶
func (*Volume) MaterialAt ¶
type VolumeWindow ¶
Source 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
Click to show internal directories.
Click to hide internal directories.