light

package
v0.0.0-...-ddc071b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 26, 2023 License: GPL-3.0 Imports: 5 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ATTENUATED_LIGHT  = 1
	DIRECTIONAL_LIGHT = 2
	AREA_LIGHT        = 3
	WATTS             = 0 // Default unit
	LUMENS            = 1
)
View Source
const (
	SP_VIOLET = 380.0
	SP_RED    = 625.0
	WATT      = 0
	LUX       = 1
)
View Source
const (
	SPD_B = 9.6
	SPD_C = 3.1
	SPD_K = 1.68
	SPD_G = 0.45
)

Sunlight Distribution Variables

Variables

This section is empty.

Functions

func RGBToXYZ

func RGBToXYZ(rgb [3]float32) [3]float32

func SunlightSpectrum

func SunlightSpectrum(nm float64) float64

------------INLINE FUNCTIONS FOR RETURNING SUN COEFFICIENT SPECTRUM---------

func SunlightSpectrumAttenuate

func SunlightSpectrumAttenuate(nm float64, k_atten float64) float64

SPD Burr Sunlight Distribution Model Attenuated by k_atten factor

func XYZToRGB

func XYZToRGB(xyz [3]float32) [3]float32

Types

type Area

type Area struct {
	Pos     vector.Vec
	Norm    vector.Vec
	Cuttoff float32
	Lum     Source
}

Area lights are attenuated lights with a restrictive projected solid angle. For a point to recieve light it must be encapsulate by the projecting solid angle. Lux is taken to a total output across this solid angle max

func (Area) GetDir

func (p Area) GetDir() vector.Vec

func (Area) GetFlux

func (p Area) GetFlux() float32

func (Area) GetRGB

func (p Area) GetRGB() vector.Vec

func (Area) Lx

func (p Area) Lx() *Source

func (Area) Position

func (p Area) Position() vector.Vec

func (Area) SetDir

func (p Area) SetDir(a vector.Vec)

func (Area) SetFlux

func (p Area) SetFlux(a float32)

func (Area) SetPos

func (p Area) SetPos(a vector.Vec)

func (Area) SetRGB

func (p Area) SetRGB(a vector.Vec)

func (Area) Type

func (p Area) Type() int

type Attenuated

type Attenuated struct {
	Pos vector.Vec
	Lum Source
}

Attenuated lights cast a total luminance across a unit sphere which amounts inverse squared attenuation factor given the total luminal output in lux. Attenuated lights are synonymous with point lights.

func (Attenuated) GetDir

func (p Attenuated) GetDir() vector.Vec

func (Attenuated) GetFlux

func (p Attenuated) GetFlux() float32

func (Attenuated) GetRGB

func (p Attenuated) GetRGB() vector.Vec

func (Attenuated) Lx

func (p Attenuated) Lx() *Source

func (Attenuated) Position

func (p Attenuated) Position() vector.Vec

func (Attenuated) SetDir

func (p Attenuated) SetDir(a vector.Vec)

func (Attenuated) SetFlux

func (p Attenuated) SetFlux(a float32)

func (Attenuated) SetPos

func (p Attenuated) SetPos(a vector.Vec)

func (Attenuated) SetRGB

func (p Attenuated) SetRGB(a vector.Vec)

func (Attenuated) Type

func (p Attenuated) Type() int

type CoefficientSpectrum

type CoefficientSpectrum struct {
	Samples []float32
	Type    int
	Wv_a    float32 //Wavelength start violet
	Wv_b    float32 //Wavelngth end red
}

Coefficient Spectrum

func (*CoefficientSpectrum) Add

Adds to samples together no error checking out of bounds responsible for caller

func (*CoefficientSpectrum) Clamp

func (ref *CoefficientSpectrum) Clamp(low float32, high float32) Spectrum

func (*CoefficientSpectrum) Div

Divides samples together no error checking out of bounds responsible for caller

func (*CoefficientSpectrum) InitSpectrum

func (ref *CoefficientSpectrum) InitSpectrum(steps int, total_power float32) Spectrum

------------------Coefficient Spectrum--------------------------------------

func (*CoefficientSpectrum) IsBlack

func (ref *CoefficientSpectrum) IsBlack() bool

func (*CoefficientSpectrum) IsNaN

func (ref *CoefficientSpectrum) IsNaN() bool

func (*CoefficientSpectrum) IsWatts

func (ref *CoefficientSpectrum) IsWatts() bool

func (*CoefficientSpectrum) Lerp

func (ref *CoefficientSpectrum) Lerp(m Spectrum, t float32) Spectrum

func (*CoefficientSpectrum) Mul

Multiplies samples together no error checking out of bounds responsible for caller

func (*CoefficientSpectrum) Neg

func (ref *CoefficientSpectrum) Neg() Spectrum

func (*CoefficientSpectrum) Pow

func (ref *CoefficientSpectrum) Pow(k float32) Spectrum

func (*CoefficientSpectrum) Sample

func (ref *CoefficientSpectrum) Sample(n int) float32

Gets the Sampler Photon from sampler slice

func (*CoefficientSpectrum) Set

func (ref *CoefficientSpectrum) Set(index int, value float32)

Sets sampler coefficient

func (*CoefficientSpectrum) Sqrt

func (ref *CoefficientSpectrum) Sqrt() Spectrum

func (*CoefficientSpectrum) Sub

Subs samples together no error checking out of bounds responsible for caller

func (*CoefficientSpectrum) Units

func (ref *CoefficientSpectrum) Units() int

func (*CoefficientSpectrum) Wavelength

func (ref *CoefficientSpectrum) Wavelength(n int) float32

Gets the Sampler Photon from sampler slice

func (*CoefficientSpectrum) WriteJSON

func (ref *CoefficientSpectrum) WriteJSON(filename string, name string, id int)

type CylinderLight

type CylinderLight struct {
	SampleLx  *Area
	Luminance float32 //Total output
	Pos       vector.Vec
	Axis      vector.Vec
	Length    float32
}

Cylindrical lights are simply a line of oriented attenuated lights

type Directional

type Directional struct {
	Pos vector.Vec
	Dir vector.Vec
	Lum Source
}

Directional lights are infinite lights with apparent-non local divergence for ray paths. Typically position is not a factor for directional lights but we may model occlusions etc with a position

func (Directional) GetDir

func (p Directional) GetDir() vector.Vec

func (Directional) GetFlux

func (p Directional) GetFlux() float32

func (Directional) GetRGB

func (p Directional) GetRGB() vector.Vec

func (Directional) Lx

func (p Directional) Lx() *Source

func (Directional) Position

func (p Directional) Position() vector.Vec

func (Directional) SetDir

func (p Directional) SetDir(a vector.Vec)

func (Directional) SetFlux

func (p Directional) SetFlux(a float32)

func (Directional) SetPos

func (p Directional) SetPos(a vector.Vec)

func (Directional) SetRGB

func (p Directional) SetRGB(a vector.Vec)

func (Directional) Type

func (p Directional) Type() int

type DiscLight

type DiscLight struct {
	SampleLx  *Area
	Luminance float32
	Pos       vector.Vec
	Dir       vector.Vec
	Radius    vector.Vec
}

type Light

type Light interface {
	Lx() *Source
	Position() vector.Vec
	Type() int
	SetRGB(vector.Vec)
	GetRGB() vector.Vec
	GetFlux() float32
	SetFlux(float32)
	SetPos(vector.Vec)
	GetDir() vector.Vec
	SetDir(vector.Vec)
}

type LightIntegral

type LightIntegral interface {
	Lights() []Light
	Luminance(point vector.Vec) float32
	Position() vector.Vec
}

Approximates area light for contributions.

type Probe

type Probe struct {
	//Lights   LightRig
	Size     float32
	Dims     [3]int
	Position vector.Vec
	Samples  int
}

type RectLight

type RectLight struct {
	SampleLx   *Area
	Lum        float32 //Total output
	Pos        vector.Vec
	Width      float32
	Height     float32
	Num_w      float32
	Num_h      float32
	EdgeCutoff float32
	Plane      []vector.Vec //Triangle plane represents object
}

Rect lights sample the light boundaries luminance is distributed across the planar region. Lights can be handled as virtual area lights with 180 cutoff becaues the output energy is distributed evenly by the area the normal light point vectors estimate the contribution while output is conserved.

func NewRectLight

func NewRectLight(color vector.Vec, lum float32, pos vector.Vec, width float32,
	height float32, num_w int, num_h int) *RectLight

func (*RectLight) Lights

func (light *RectLight) Lights() []Area

Area light is defined by a planar orientation given by the planar matrix This calculates all light positions and returns an array for the given light

func (*RectLight) Luminance

func (light *RectLight) Luminance(point vector.Vec) float32

Placeholder body

func (*RectLight) Position

func (light *RectLight) Position() vector.Vec

type SampledSpectrum

type SampledSpectrum struct {
	SPD                 Spectrum
	Samples             int
	CoefficientSpectrum CoefficientSpectrum
	// contains filtered or unexported fields
}

Sampled Spectrum holds an SPD and references to CIE XYZ sampled Spectrums cieX , cieY, cieZ should be references only.

func InitSampledSpectrum

func InitSampledSpectrum(v float32, n float32) *SampledSpectrum

-----------------------Sampled Spectrum------------------------------------ Returns Sampled spectrum with default constructions - returns nil for invalid

func (*SampledSpectrum) Add_CIEX

func (ref *SampledSpectrum) Add_CIEX(spd_ciex *CoefficientSpectrum)

Allocates CIEX infrastructre

func (*SampledSpectrum) Add_CIEY

func (ref *SampledSpectrum) Add_CIEY(spd_ciey *CoefficientSpectrum)

Allocates CIEY infrastructre

func (*SampledSpectrum) Add_CIEZ

func (ref *SampledSpectrum) Add_CIEZ(spd_ciez *CoefficientSpectrum)

Allocates CIEZ infrastructure

func (*SampledSpectrum) FromFile

func (ref *SampledSpectrum) FromFile(file string) error

Imports SPD into currently allocated Sampled Spectrum Type

func (*SampledSpectrum) FromSampled

func (ref *SampledSpectrum) FromSampled(wv []float32, v []float32) error

We assume that the sample arrays are sorted - returns error if we can detect an unordered sample sapce or the data sets arent correlated

func (*SampledSpectrum) ToRGB

func (ref *SampledSpectrum) ToRGB() [3]float32

func (*SampledSpectrum) ToXYZ

func (ref *SampledSpectrum) ToXYZ() [3]float32

Returns SPD in form of device independent XYZ color coordinates

func (*SampledSpectrum) WriteJSON

func (ref *SampledSpectrum) WriteJSON(filename string, name string, id int)

JSON Writing

func (*SampledSpectrum) YY

func (ref *SampledSpectrum) YY() float32

type Source

type Source struct {
	RGB  vector.Vec
	Flux float32
	Unit int
}

Source - Luminous Flux and Light Color in RGB Color Space. Systems dependent on physical light interaction such as absorption, scattering should use light.SPD Units are either based in Watts or Lumens per meter area

type Spectrum

type Spectrum interface {
	InitSpectrum(samples int, total_power float32) Spectrum
	Sample(n int) float32
	Set(index int, value float32)
	Wavelength(n int) float32
	Units() int
	IsWatts() bool
	IsBlack() bool
	IsNaN() bool
	Add(Spectrum) Spectrum
	Mul(Spectrum) Spectrum
	Div(Spectrum) Spectrum
	Sub(Spectrum) Spectrum
	Neg() Spectrum
	Sqrt() Spectrum
	Lerp(Spectrum, float32) Spectrum
	Pow(k float32) Spectrum
	Clamp(low float32, high float32) Spectrum
	WriteJSON(filename string, name string, id int)
}

func InitSunlight

func InitSunlight(steps int) Spectrum

------------------Coefficient Spectrum--------------------------------

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL