Documentation
¶
Overview ¶
Package sampler provides a generic interface for intersection samplers, and implementations for simple samplers (colour, number etc) and image textures
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AnySampler ¶
type AnySampler struct {
Sampler
}
AnySampler implements the Sampler interface and is deserialiseable from json
func (*AnySampler) UnmarshalJSON ¶
func (s *AnySampler) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
type ImageTexture ¶
ImageTexture is.. an image texture!
func (*ImageTexture) GetColour ¶
func (i *ImageTexture) GetColour(intersection *ray.Intersection) *hdrcolour.Colour
GetColour returns the colour at (u, v)
func (*ImageTexture) GetFac ¶
func (i *ImageTexture) GetFac(intersection *ray.Intersection) float64
GetFac returns the colour intensity at (u, v)
func (*ImageTexture) GetVec3 ¶
func (i *ImageTexture) GetVec3(intersection *ray.Intersection) *maths.Vec3
GetVec3 returns the colour at (u, v)'s components as a vector
func (*ImageTexture) UnmarshalJSON ¶
func (i *ImageTexture) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
type NumberSampler ¶
NumberSampler is a sampler constructed by a single number
Example ¶
var sampler *NumberSampler err := json.Unmarshal([]byte(`42`), &sampler) if err != nil { fmt.Printf("can't unmarshal data: %s\n", err) return } fmt.Printf("Vector sample: %s\n", sampler.GetVec3(nil)) fmt.Printf("Colour sample: %s\n", sampler.GetColour(nil)) fmt.Printf("Fac sample: %.3g\n", sampler.GetFac(nil))
Output: Vector sample: (42, 42, 42) Colour sample: {42, 42, 42} Fac sample: 42
func (*NumberSampler) GetColour ¶
func (n *NumberSampler) GetColour(intersection *ray.Intersection) *hdrcolour.Colour
GetColour returns a colour with R, G, B equal to the number (doesn't need a valid intersection)
func (*NumberSampler) GetFac ¶
func (n *NumberSampler) GetFac(intersection *ray.Intersection) float64
GetFac returns the number (doesn't need a valid intersection)
func (*NumberSampler) GetVec3 ¶
func (n *NumberSampler) GetVec3(intersection *ray.Intersection) *maths.Vec3
GetVec3 returns a vector with X, Y, Z equal to the number (doesn't need a valid intersection)
func (*NumberSampler) UnmarshalJSON ¶
func (n *NumberSampler) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface
type Sampler ¶
type Sampler interface { GetColour(intersection *ray.Intersection) *hdrcolour.Colour GetVec3(intersection *ray.Intersection) *maths.Vec3 GetFac(intersectuib *ray.Intersection) float64 }
Sampler objects return varying attributes on points on surfaces (e.g. texture colours, ray information etc)
type Vec3Sampler ¶
Vec3Sampler is a sampler constructed by 3 numbers
Example ¶
var sampler *Vec3Sampler err := json.Unmarshal([]byte(`[0.1, 0.5, 0.3]`), &sampler) if err != nil { fmt.Printf("can't unmarshal data: %s\n", err) return } fmt.Printf("Vector sample: %s\n", sampler.GetVec3(nil)) fmt.Printf("Colour sample: %s\n", sampler.GetColour(nil)) fmt.Printf("Fac sample: %.3g\n", sampler.GetFac(nil))
Output: Vector sample: (0.1, 0.5, 0.3) Colour sample: {0.1, 0.5, 0.3} Fac sample: 0.3
func (*Vec3Sampler) GetColour ¶
func (v *Vec3Sampler) GetColour(intersection *ray.Intersection) *hdrcolour.Colour
GetColour returns a colour with R, G, B corresponding to the 3 components (doesn't need a valid intersection)
func (*Vec3Sampler) GetFac ¶
func (v *Vec3Sampler) GetFac(intersection *ray.Intersection) float64
GetFac returns a number that is the average of the 3 components (doesn't need a valid intersection)
func (*Vec3Sampler) GetVec3 ¶
func (v *Vec3Sampler) GetVec3(intersection *ray.Intersection) *maths.Vec3
GetVec3 returns a vector with X, Y, Z corresponding to the 3 components (doesn't need a valid intersection)
func (*Vec3Sampler) UnmarshalJSON ¶
func (v *Vec3Sampler) UnmarshalJSON(data []byte) error
UnmarshalJSON implements the json.Unmarshaler interface