optics

package
v0.0.0-...-98f3f52 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WavelengthMin = 380.0
	WavelengthMax = 750.0
)

Variables

This section is empty.

Functions

func ContextWavelengthsNM

func ContextWavelengthsNM(ctx WavelengthContext) []float64

func SpectralRayToScalar

func SpectralRayToScalar(ray *Ray) float64

func SpectralSampleRadiance

func SpectralSampleRadiance(power, pdf float64) float64

func SrgbChannelToLinear

func SrgbChannelToLinear(v float64) float64

func UniformWavelengthPDF

func UniformWavelengthPDF() float64

func XYZToLinearSRGB

func XYZToLinearSRGB(x, y, z float64) (float64, float64, float64)

Types

type ACEScg

type ACEScg = Color3

func NewACEScg

func NewACEScg(r, g, b float64) ACEScg

type Color3

type Color3 [3]float64

func (Color3) Add

func (c Color3) Add(other Color3) Color3

func (Color3) At

func (c Color3) At(i int) float64

func (Color3) Average

func (c Color3) Average() float64

func (Color3) B

func (c Color3) B() float64

func (Color3) ClampMin

func (c Color3) ClampMin(minValue float64) Color3

func (Color3) DivScalar

func (c Color3) DivScalar(v float64) Color3

func (Color3) G

func (c Color3) G() float64

func (Color3) IsFinite

func (c Color3) IsFinite() bool

func (Color3) IsNonNegative

func (c Color3) IsNonNegative() bool

func (Color3) IsZero

func (c Color3) IsZero() bool

func (Color3) Max

func (c Color3) Max() float64

func (Color3) Mul

func (c Color3) Mul(other Color3) Color3

func (Color3) MulScalar

func (c Color3) MulScalar(v float64) Color3

func (Color3) R

func (c Color3) R() float64

type PathState

type PathState struct {
	Throughput float64           `json:"throughput"`
	Radiance   float64           `json:"radiance"`
	Wavelength *WavelengthSample `json:"wavelength,omitempty"`
}

PathState carries scalar power at exactly one sampled wavelength. Authored RGB never enters this state; materials resolve it through SpectralParameter before transport updates Throughput or Radiance.

type RGB

type RGB = Color3

func NewRGB

func NewRGB(r, g, b float64) RGB

func RGBWeight

func RGBWeight(wavelength float64) RGB

func WavelengthToLinearSRGB

func WavelengthToLinearSRGB(wavelength float64) RGB

func WavelengthToRGB

func WavelengthToRGB(wavelength float64) RGB

type RGBColorSpace

type RGBColorSpace string
const (
	RGBColorSpaceLinearSRGB RGBColorSpace = "linear_srgb"
	RGBColorSpaceSRGB       RGBColorSpace = "srgb"
	RGBColorSpaceACEScg     RGBColorSpace = "acescg"
)

type Ray

type Ray struct {
	Origin      *mat.VecDense       `json:"origin"`
	Direction   *mat.VecDense       `json:"direction"`
	Path        PathState           `json:"path"`
	MediumStack medium.Stack        `json:"-"`
	Space       geometry.SceneSpace `json:"-"`
	ArcTraveled float64             `json:"-"` // geodesic arc length traveled so far (S^3 wrap)
}

func (*Ray) ConvertToMonochrome

func (r *Ray) ConvertToMonochrome()

func (*Ray) DisableSpectralSampling

func (r *Ray) DisableSpectralSampling()

func (*Ray) G

func (r *Ray) G() geometry.Geometry

G returns the ray's geometry, falling back to Euclidean if unset.

func (*Ray) Init

func (r *Ray) Init()

func (*Ray) SampleWavelength

func (r *Ray) SampleWavelength(sample float64)

func (*Ray) SetMonochrome

func (r *Ray) SetMonochrome(wavelength float64)

func (*Ray) SetSpectralSample

func (r *Ray) SetSpectralSample(sample WavelengthSample)

func (*Ray) SetSpectralWavelength

func (r *Ray) SetSpectralWavelength(wavelength float64)

type SpectralParameter

type SpectralParameter interface {
	Eval(ctx WavelengthContext) Spectrum
	Bounds() SpectrumBounds
}

type Spectrum

type Spectrum struct {
	Kind    SpectrumKind
	RGB     RGB
	Power   float64
	Samples []float64
}

Spectrum is a transient material-evaluation value, not transport-path state. Authored RGB is scene-linear sRGB. Transport paths resolve it to an inline scalar at their selected wavelength; sampled vectors are for batched/offline parameter evaluation and intentionally do not mirror RGB channels.

func ConstantSpectrum

func ConstantSpectrum(v float64) Spectrum

func NewRGBSpectrum

func NewRGBSpectrum(r, g, b float64) Spectrum

func NewSampledSpectrum

func NewSampledSpectrum(samples []float64) Spectrum

func NewSpectralPower

func NewSpectralPower(power float64) Spectrum

func NewSpectrum

func NewSpectrum(r, g, b float64) Spectrum

func SampledSpectrumToLinearSRGB

func SampledSpectrumToLinearSRGB(wavelengthsNM, values []float64) Spectrum

func (Spectrum) Add

func (s Spectrum) Add(other Spectrum) Spectrum

func (Spectrum) AlmostEqual

func (s Spectrum) AlmostEqual(other Spectrum, eps float64) bool

func (Spectrum) Average

func (s Spectrum) Average() float64

func (Spectrum) AverageRGB

func (s Spectrum) AverageRGB() float64

func (Spectrum) Clone

func (s Spectrum) Clone() Spectrum

func (Spectrum) DivScalar

func (s Spectrum) DivScalar(v float64) Spectrum

func (Spectrum) HasSamples

func (s Spectrum) HasSamples() bool

func (Spectrum) IsFinite

func (s Spectrum) IsFinite() bool

func (Spectrum) IsNonNegative

func (s Spectrum) IsNonNegative() bool

func (Spectrum) IsZero

func (s Spectrum) IsZero() bool

func (Spectrum) MaxComponent

func (s Spectrum) MaxComponent() float64

func (Spectrum) Mul

func (s Spectrum) Mul(other Spectrum) Spectrum

func (Spectrum) MulScalar

func (s Spectrum) MulScalar(v float64) Spectrum

func (Spectrum) PowerAt

func (s Spectrum) PowerAt(wavelengthNM float64) (float64, bool)

PowerAt resolves a renderer value to one scalar spectral power sample. Authored RGB is uplifted only at this boundary; multi-sample values cannot be collapsed without an explicit wavelength-to-index association.

func (Spectrum) RGBChannel

func (s Spectrum) RGBChannel(i int) float64

func (Spectrum) RGBPowerAtWavelength

func (s Spectrum) RGBPowerAtWavelength(wavelengthNM float64) float64

func (Spectrum) RGBReflectancePowerAt

func (s Spectrum) RGBReflectancePowerAt(wavelengthNM float64) float64

func (Spectrum) Sample

func (s Spectrum) Sample(i int) float64

func (Spectrum) SampleCount

func (s Spectrum) SampleCount() int

func (Spectrum) UpliftRGBReflectanceToSampled

func (s Spectrum) UpliftRGBReflectanceToSampled(wavelengthsNM []float64) Spectrum

func (Spectrum) UpliftRGBToSampled

func (s Spectrum) UpliftRGBToSampled(wavelengthsNM []float64) Spectrum

type SpectrumBounds

type SpectrumBounds struct {
	Min Spectrum
	Max Spectrum
}

type SpectrumKind

type SpectrumKind int
const (
	SpectrumKindRGB SpectrumKind = iota
	SpectrumKindScalar
	SpectrumKindSampled
)

type UniformWavelengthSampler

type UniformWavelengthSampler struct {
	MinNM float64
	MaxNM float64
}

func NewUniformWavelengthSampler

func NewUniformWavelengthSampler() UniformWavelengthSampler

func (UniformWavelengthSampler) Sample

type WavelengthBatchContext

type WavelengthBatchContext interface {
	SpectralWavelengthsNM() []float64
}

WavelengthBatchContext is an optional extension for explicit batched/offline parameter evaluation. Runtime transport contexts intentionally do not implement it because one path owns exactly one wavelength.

type WavelengthContext

type WavelengthContext interface {
	SpectralWavelengthNM() float64
}

type WavelengthSample

type WavelengthSample struct {
	LambdaNM float64
	PDF      float64
}

type WavelengthSampler

type WavelengthSampler interface {
	Sample(u float64) WavelengthSample
}

type WavelengthWeightFunc

type WavelengthWeightFunc func(wavelengthNM float64) float64

type WeightedWavelengthSampler

type WeightedWavelengthSampler struct {
	MinNM float64 // Lower wavelength bound in nanometers.
	MaxNM float64 // Upper wavelength bound in nanometers.
	Bins  int     // Number of wavelength intervals.
	// contains filtered or unexported fields
}

func NewCIESensitivityWavelengthSampler

func NewCIESensitivityWavelengthSampler(bins int) WeightedWavelengthSampler

func NewCompositeWavelengthSampler

func NewCompositeWavelengthSampler(bins int, weights ...WavelengthWeightFunc) WeightedWavelengthSampler

func NewRGBImportanceWavelengthSampler

func NewRGBImportanceWavelengthSampler(rgb Spectrum, bins int) WeightedWavelengthSampler

func NewWeightedWavelengthSampler

func NewWeightedWavelengthSampler(minNM, maxNM float64, bins int, weight WavelengthWeightFunc) WeightedWavelengthSampler

func (WeightedWavelengthSampler) Sample

type XYZ

type XYZ = Color3

func NewXYZ

func NewXYZ(x, y, z float64) XYZ

func SpectralPowerToXYZ

func SpectralPowerToXYZ(wavelength, pdf, power float64) XYZ

func WavelengthToNormalizedXYZ

func WavelengthToNormalizedXYZ(wavelength, pdf float64) XYZ

func WavelengthToXYZ

func WavelengthToXYZ(wavelength float64) XYZ

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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