Documentation ¶
Index ¶
- Constants
- Variables
- type Camera
- type Color
- func (a Color) Add(b Color) Color
- func (a Color) AddS(b float64) Color
- func (c Color) ConvertToRGBA() color.RGBA
- func (a Color) Div(b Color) Color
- func (a Color) DivS(b float64) Color
- func (a Color) Mul(b Color) Color
- func (a Color) MulS(b float64) Color
- func (a Color) Sub(b Color) Color
- func (a Color) SubS(b float64) Color
- type Light
- type Material
- type Object
- type Ray
- type Scene
- type Sphere
- type Vector
- func (a Vector) Abs() Vector
- func (a Vector) Add(b Vector) Vector
- func (a Vector) AddS(b float64) Vector
- func (a Vector) Cross(b Vector) Vector
- func (a Vector) Div(b Vector) Vector
- func (a Vector) DivS(b float64) Vector
- func (a Vector) Dot(b Vector) float64
- func (a Vector) Length() float64
- func (a Vector) LengthSquared() float64
- func (a Vector) Mul(b Vector) Vector
- func (a Vector) MulS(b float64) Vector
- func (a Vector) Negate() Vector
- func (a Vector) Normalize() Vector
- func (a Vector) Sub(b Vector) Vector
- func (a Vector) SubS(b float64) Vector
Constants ¶
View Source
const MaxTraceDepth = 3 // The maximum depth for trace recursion
Variables ¶
View Source
var ( Zero = NewVec(0, 0, 0) UnitX = NewVec(1, 0, 0) UnitY = NewVec(0, 1, 0) UnitZ = NewVec(0, 0, 1) Identity = NewVec(1, 1, 1) )
Commonly used vectors
View Source
var ( Black = NewColor(0, 0, 0) Red = NewColor(1, 0, 0) Green = NewColor(0, 1, 0) Blue = NewColor(0, 0, 1) White = NewColor(1, 1, 1) )
Commonly used colors
Functions ¶
This section is empty.
Types ¶
type Camera ¶
type Camera struct {
FieldOfView float64 // The field of view, in degrees
}
Represents a camera within the scene
type Color ¶
type Color struct {
R, G, B float64
}
Represents a color composed of red, green and blue
func (Color) ConvertToRGBA ¶
Converts a color in floating point range (0.0 to 1.0) to a color with the given channel values
type Light ¶
type Light struct { Position Vector // The position of the light Emissive Color // The emissive color of the light }
Represents a light in the scene
type Material ¶
type Material struct { Diffuse Color // The diffuse color of the material Transparency float64 // The transparency level of the material (between 0.0 and 1.0 inclusive) Reflectivity float64 // The reflectivity level of the material (between 0.0 and 1.0 inclusive) }
Describes the material surface of an object within a scene
type Object ¶
type Object interface { // Calculates whether the object Intersects the given ray and returns the distance. Intersects(ray Ray, distance *float64) bool GetMaterial() Material // The material of the object GetPosition() Vector // The center position of the object }
Represents an object in the scene
type Ray ¶
type Ray struct {
Origin, Direction Vector
}
Represents a ray projected in 3d space
type Scene ¶
type Scene struct { Camera Camera // The scene camera Lights []Light // The world light sources Objects []Object // The objects composing the scene itself BackgroundColor Color // The background color of the scene }
Represents a scene configuration for the ray-tracer; provides objects and materials which compose the scene structure and layout
type Sphere ¶
Represents a sphere that can be placed in a scene
func (Sphere) GetMaterial ¶
func (Sphere) GetPosition ¶
type Vector ¶
type Vector struct {
X, Y, Z float64
}
Represents a vector in 3d space
func (Vector) LengthSquared ¶
Calculates the square length of this vector
Click to show internal directories.
Click to hide internal directories.