Documentation ¶
Index ¶
- Constants
- Variables
- func ClampInt(x, lo, hi int) int
- func Degrees(radians float64) float64
- func DurationString(d time.Duration) string
- func Fract(x float64) float64
- func LoadJPG(path string) (image.Image, error)
- func LoadMTL(path string, parent Material, materials map[string]*Material) error
- func LoadPNG(path string) (image.Image, error)
- func Median(items []float64) float64
- func NumberString(x float64) string
- func ParseFloats(items []string) []float64
- func ParseInts(items []string) []int
- func Radians(degrees float64) float64
- func RelativePath(path1, path2 string) string
- func Render(scene *Scene, camera *Camera) chan pixelRenderResult
- func RenderToWindow(pixelRenderResult chan pixelRenderResult)
- func SaveBinarySTL(path string, mesh *Mesh) error
- func SavePNG(path string, im image.Image) error
- type Attenuation
- type Axis
- type Box
- type Camera
- 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) Min(b Color) Color
- 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) Sub(b Color) Color
- type ColorTexture
- type Cube
- type Hit
- type HitInfo
- 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, attenuation Attenuation) 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, fovy float64) 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 (m *Mesh) Box() Box
- func (m *Mesh) Color(p Vector) Color
- func (m *Mesh) Compile()
- func (m *Mesh) FitInside(box Box, anchor Vector)
- func (m *Mesh) Intersect(r Ray) Hit
- func (m *Mesh) Material(p Vector) Material
- func (m *Mesh) MoveTo(position, anchor Vector)
- func (m *Mesh) Normal(p Vector) Vector
- func (m *Mesh) RandomPoint() Vector
- func (m *Mesh) SaveBinarySTL(path string) error
- func (m *Mesh) SmoothNormals()
- func (m *Mesh) SmoothNormalsThreshold(radians float64)
- func (m *Mesh) Transform(matrix Matrix)
- func (m *Mesh) Triangles() []*Triangle
- func (m *Mesh) UnitCube()
- func (m *Mesh) UpdateBox()
- type Node
- type Ray
- func (i Ray) Bounce(info *HitInfo, p, u, v float64) (Ray, bool)
- func (r Ray) ConeBounce(theta, u, v float64) 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) Ray
- type STLHeader
- type STLTriangle
- type Scene
- func (s *Scene) Add(shape Shape)
- func (s *Scene) Compile()
- func (s *Scene) DirectLight(n Ray) Color
- func (s *Scene) Intersect(r Ray) Hit
- func (s *Scene) RayCount() uint64
- func (s *Scene) Sample(r Ray, emission bool, samples, depth int) Color
- func (s *Scene) SetColor(color Color)
- func (s *Scene) SetVisibility(visibility float64)
- func (s *Scene) Shadow(r Ray, light Shape, max float64) bool
- type Shape
- type Sphere
- type Texture
- type TransformedShape
- type Tree
- type Triangle
- func (t *Triangle) Area() float64
- func (t *Triangle) Barycentric(p Vector) (u, v, w float64)
- func (t *Triangle) Box() Box
- func (t *Triangle) Color(p Vector) Color
- func (t *Triangle) Compile()
- func (t *Triangle) FixNormals()
- func (t *Triangle) Intersect(r Ray) Hit
- func (t *Triangle) Material(p Vector) Material
- func (t *Triangle) Normal(p Vector) Vector
- func (t *Triangle) RandomPoint() Vector
- func (t *Triangle) UpdateBox()
- func (t *Triangle) Vertices() (Vector, Vector, Vector)
- type Vector
- func (a Vector) Add(b Vector) 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) Max(b Vector) Vector
- func (a Vector) Min(b Vector) Vector
- func (a Vector) MinAxis() Vector
- func (a Vector) MinComponent() float64
- func (a Vector) Mul(b Vector) Vector
- func (a Vector) MulScalar(b float64) 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
Constants ¶
View Source
const EPS = 1e-9
View Source
const INF = 1e9
Variables ¶
View Source
var NoAttenuation = Attenuation{1, 0, 0}
View Source
var NoHit = Hit{nil, INF}
Functions ¶
func DurationString ¶
func NumberString ¶
func ParseFloats ¶
func RelativePath ¶
func RenderToWindow ¶
func RenderToWindow(pixelRenderResult chan pixelRenderResult)
func SaveBinarySTL ¶
Types ¶
type Attenuation ¶
func LinearAttenuation ¶
func LinearAttenuation(x float64) Attenuation
func QuadraticAttenuation ¶
func QuadraticAttenuation(x float64) Attenuation
func (*Attenuation) Compute ¶
func (a *Attenuation) Compute(d float64) float64
type ColorTexture ¶
type ColorTexture struct {
// contains filtered or unexported fields
}
func (*ColorTexture) BumpSample ¶
func (t *ColorTexture) BumpSample(u, v float64) Vector
func (*ColorTexture) NormalSample ¶
func (t *ColorTexture) NormalSample(u, v float64) Vector
func (*ColorTexture) Sample ¶
func (t *ColorTexture) Sample(u, v float64) Color
type Cube ¶
type Cube struct {
// contains filtered or unexported fields
}
func (*Cube) RandomPoint ¶
type Material ¶
type Material struct { Color Color Texture Texture NormalTexture Texture BumpTexture Texture BumpMultiplier float64 Emittance float64 Attenuation Attenuation Index float64 // refractive index Gloss float64 // reflection cone angle in radians Tint float64 // specular and refractive tinting Transparent bool }
func ClearMaterial ¶
func DiffuseMaterial ¶
func GlossyMaterial ¶
func LightMaterial ¶
func LightMaterial(color Color, emittance float64, attenuation Attenuation) Material
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 {
// contains filtered or unexported fields
}
func (*Mesh) RandomPoint ¶
func (*Mesh) SaveBinarySTL ¶
func (*Mesh) SmoothNormals ¶
func (m *Mesh) SmoothNormals()
func (*Mesh) SmoothNormalsThreshold ¶
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
func (*Node) IntersectShapes ¶
type Ray ¶
type Ray struct {
Origin, Direction Vector
}
func (Ray) ConeBounce ¶
func (Ray) WeightedBounce ¶
type STLTriangle ¶
type STLTriangle struct {
V1, V2, V3 [3]float32
// contains filtered or unexported fields
}
type Scene ¶
type Scene struct {
// contains filtered or unexported fields
}
func (*Scene) DirectLight ¶
func (*Scene) SetVisibility ¶
type Shape ¶
type Shape interface { Compile() Box() Box Intersect(Ray) Hit Color(Vector) Color Material(Vector) Material Normal(Vector) Vector RandomPoint() Vector }
func NewTransformedShape ¶
type Sphere ¶
type Sphere struct {
// contains filtered or unexported fields
}
func (*Sphere) RandomPoint ¶
type Texture ¶
type Texture interface { Sample(u, v float64) Color NormalSample(u, v float64) Vector BumpSample(u, v float64) Vector }
func GetTexture ¶
func JPGTexture ¶
func LoadTexture ¶
func NewTexture ¶
func PNGTexture ¶
type TransformedShape ¶
type TransformedShape struct { Shape // contains filtered or unexported fields }
func (*TransformedShape) Box ¶
func (s *TransformedShape) Box() Box
func (*TransformedShape) Color ¶
func (s *TransformedShape) Color(p Vector) Color
func (*TransformedShape) Intersect ¶
func (s *TransformedShape) Intersect(r Ray) Hit
func (*TransformedShape) Material ¶
func (s *TransformedShape) Material(p Vector) Material
func (*TransformedShape) Normal ¶
func (s *TransformedShape) Normal(p Vector) Vector
func (*TransformedShape) RandomPoint ¶
func (s *TransformedShape) RandomPoint() Vector
type Triangle ¶
type Triangle struct {
// contains filtered or unexported fields
}
func NewTriangle ¶
func (*Triangle) Barycentric ¶
func (*Triangle) FixNormals ¶
func (t *Triangle) FixNormals()
func (*Triangle) RandomPoint ¶
type Vector ¶
type Vector struct {
X, Y, Z float64
}
func PoissonDisc ¶
func (Vector) MinComponent ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.