raytrace

package
v0.0.0-...-a1fb13a Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRandomCosineDirection

func GetRandomCosineDirection() mgl64.Vec3

func PerlinNoise

func PerlinNoise(p mgl64.Vec3, interpolate bool) float64

func PerlinVectorNoise

func PerlinVectorNoise(p mgl64.Vec3) float64

func PerlinVectorTurbulence

func PerlinVectorTurbulence(p mgl64.Vec3) float64

func PerlinVectorTurbulenceCustomDepth

func PerlinVectorTurbulenceCustomDepth(p mgl64.Vec3, depth int) float64

func RandomToSphere

func RandomToSphere(radius float64, distanceSquared float64) mgl64.Vec3

Types

type AABB

type AABB struct {
	// contains filtered or unexported fields
}

func NewAABB

func NewAABB(min mgl64.Vec3, max mgl64.Vec3) *AABB

func (*AABB) GetSurroundingBox

func (aabb *AABB) GetSurroundingBox(other *AABB) *AABB

func (*AABB) Hit

func (aabb *AABB) Hit(ray *Ray, tMin float64, tMax float64) bool

func (*AABB) Max

func (aabb *AABB) Max() mgl64.Vec3

func (*AABB) Min

func (aabb *AABB) Min() mgl64.Vec3

type BackgroundFunc

type BackgroundFunc func(ray *Ray) ColorVector

type Camera

type Camera interface {
	GetRay(s float64, t float64) *Ray
}

Camera todo

type ColorVector

type ColorVector struct {
	// contains filtered or unexported fields
}

func NewColorVector

func NewColorVector(r float64, g float64, b float64) ColorVector

func NewColorVectorFromRGBA

func NewColorVectorFromRGBA(r uint32, g uint32, b uint32, a uint32) ColorVector

func (ColorVector) Add

func (c ColorVector) Add(other ColorVector) ColorVector

func (ColorVector) ApplyGamma2

func (c ColorVector) ApplyGamma2() ColorVector

func (ColorVector) B

func (c ColorVector) B() float64

func (ColorVector) Clamp

func (c ColorVector) Clamp() ColorVector

func (ColorVector) DivScalar

func (c ColorVector) DivScalar(other float64) ColorVector

func (ColorVector) G

func (c ColorVector) G() float64

func (ColorVector) Mul

func (c ColorVector) Mul(other ColorVector) ColorVector

func (ColorVector) MulScalar

func (c ColorVector) MulScalar(other float64) ColorVector

func (ColorVector) R

func (c ColorVector) R() float64

func (ColorVector) RGBA

func (c ColorVector) RGBA() (r, g, b, a uint32)

type CosinePdf

type CosinePdf struct {
	// contains filtered or unexported fields
}

func (*CosinePdf) Generate

func (p *CosinePdf) Generate() mgl64.Vec3

func (*CosinePdf) GetValue

func (p *CosinePdf) GetValue(direction mgl64.Vec3) float64

type HitRecord

type HitRecord struct {
	// contains filtered or unexported fields
}

func NewHitRecord

func NewHitRecord(t float64, p mgl64.Vec3, normal mgl64.Vec3, uvCoords mgl64.Vec2, material Material) *HitRecord

func (*HitRecord) Material

func (hr *HitRecord) Material() Material

func (*HitRecord) Normal

func (hr *HitRecord) Normal() mgl64.Vec3

func (*HitRecord) P

func (hr *HitRecord) P() mgl64.Vec3

func (*HitRecord) T

func (hr *HitRecord) T() float64

func (*HitRecord) UvCoords

func (hr *HitRecord) UvCoords() mgl64.Vec2

type Hitable

type Hitable interface {
	Hit(ray *Ray, tMin float64, tMax float64) *HitRecord
	GetBoundingBox(t0 float64, t1 float64) *AABB

	GetPdfValue(origin mgl64.Vec3, v mgl64.Vec3) float64
	Random(origin mgl64.Vec3) mgl64.Vec3
}

Hitable go

type HitablePdf

type HitablePdf struct {
	// contains filtered or unexported fields
}

func (*HitablePdf) Generate

func (p *HitablePdf) Generate() mgl64.Vec3

func (*HitablePdf) GetValue

func (p *HitablePdf) GetValue(direction mgl64.Vec3) float64

type Material

type Material interface {
	Scatter(rayIn *Ray, hitRecord *HitRecord) *ScatterResult
	ScatteringPdf(rayIn *Ray, hitRecord *HitRecord, scattered *Ray) float64
	Emitted(rayIn *Ray, hitRecord *HitRecord, uvCoords mgl64.Vec2, p mgl64.Vec3) ColorVector
}

type MixturePdf

type MixturePdf struct {
	// contains filtered or unexported fields
}

func (*MixturePdf) Generate

func (p *MixturePdf) Generate() mgl64.Vec3

func (*MixturePdf) GetValue

func (p *MixturePdf) GetValue(direction mgl64.Vec3) float64

type MonteCarloTracer

type MonteCarloTracer struct {
	// contains filtered or unexported fields
}

func (*MonteCarloTracer) Configure

func (t *MonteCarloTracer) Configure(
	imageWidth int,
	imageHeight int,
	camera Camera,
	world Hitable,
	lightHitable Hitable,
	renderConfig *RenderConfig,
	backgroundFunc BackgroundFunc)

func (*MonteCarloTracer) GetPixelColor

func (t *MonteCarloTracer) GetPixelColor(x int, y int) ColorVector

type OrthoNormalBase

type OrthoNormalBase struct {
	// contains filtered or unexported fields
}

func OrthoNormalBaseFromW

func OrthoNormalBaseFromW(n mgl64.Vec3) *OrthoNormalBase

func (*OrthoNormalBase) Local

func (onb *OrthoNormalBase) Local(a mgl64.Vec3) mgl64.Vec3

func (*OrthoNormalBase) W

func (onb *OrthoNormalBase) W() mgl64.Vec3

type Pdf

type Pdf interface {
	GetValue(direction mgl64.Vec3) float64
	Generate() mgl64.Vec3
}

func NewCosinePdf

func NewCosinePdf(w mgl64.Vec3) Pdf

func NewHitablePdf

func NewHitablePdf(hitable Hitable, origin mgl64.Vec3) Pdf

func NewMixturePdf

func NewMixturePdf(p0 Pdf, p1 Pdf) Pdf

type PixelBuffer

type PixelBuffer struct {
	// contains filtered or unexported fields
}

func LoadPixelBuffer

func LoadPixelBuffer(imagePath string) *PixelBuffer

func NewPixelBuffer

func NewPixelBuffer(width int, height int) *PixelBuffer

func (*PixelBuffer) GetImage

func (buf *PixelBuffer) GetImage() *image.RGBA

func (*PixelBuffer) GetPixelColor

func (buf *PixelBuffer) GetPixelColor(x int, y int) ColorVector

func (*PixelBuffer) Height

func (buf *PixelBuffer) Height() int

func (*PixelBuffer) SavePng

func (buf *PixelBuffer) SavePng(path string)

func (*PixelBuffer) SetPixelColor

func (buf *PixelBuffer) SetPixelColor(x int, y int, clr ColorVector)

func (*PixelBuffer) Width

func (buf *PixelBuffer) Width() int

type Ray

type Ray struct {
	// contains filtered or unexported fields
}

Ray todo

func NewRay

func NewRay(origin mgl64.Vec3, direction mgl64.Vec3) *Ray

NewRay todo

func (*Ray) Direction

func (r *Ray) Direction() mgl64.Vec3

Direction todo

func (*Ray) GetPointAtParameter

func (r *Ray) GetPointAtParameter(t float64) mgl64.Vec3

GetPointAtParameter todo

func (*Ray) Origin

func (r *Ray) Origin() mgl64.Vec3

Origin todo

type RayTracer

type RayTracer interface {
	Configure(
		imageWidth int,
		imageHeight int,
		camera Camera,
		world Hitable,
		lightHitable Hitable,
		renderConfig *RenderConfig,
		backgroundFunc BackgroundFunc)
	GetPixelColor(x int, y int) ColorVector
}

func NewMonteCarloTracer

func NewMonteCarloTracer() RayTracer

func NewSimpleTracer

func NewSimpleTracer() RayTracer

type RenderConfig

type RenderConfig struct {
	// contains filtered or unexported fields
}

func NewRenderConfig

func NewRenderConfig(maxDepth int, samplesPerPixel int, isTwoPhase bool) *RenderConfig

func (*RenderConfig) IsTwoPhase

func (c *RenderConfig) IsTwoPhase() bool

type Renderer

type Renderer struct {
	// contains filtered or unexported fields
}

func NewRenderer

func NewRenderer(config *RenderConfig) *Renderer

func (*Renderer) Render

func (r *Renderer) Render(rayTracer RayTracer, pixelBuffer *PixelBuffer, scene Scene, renderConfig *RenderConfig)

type ScatterResult

type ScatterResult struct {
	// contains filtered or unexported fields
}

func NewFalseScatterResult

func NewFalseScatterResult() *ScatterResult

func NewScatterResult

func NewScatterResult(isScattered bool, attenuation ColorVector, specularRay *Ray, pdf Pdf) *ScatterResult

func (*ScatterResult) Attenuation

func (r *ScatterResult) Attenuation() ColorVector

func (*ScatterResult) IsScattered

func (r *ScatterResult) IsScattered() bool

func (*ScatterResult) IsSpecular

func (r *ScatterResult) IsSpecular() bool

func (*ScatterResult) Pdf

func (r *ScatterResult) Pdf() Pdf

func (*ScatterResult) SpecularRay

func (r *ScatterResult) SpecularRay() *Ray

type Scene

type Scene interface {
	GetCamera(width int, height int) Camera
	GetWorld() Hitable
	GetLightHitable() Hitable
	GetBackgroundFunc() BackgroundFunc
}

func NewScene

func NewScene(camera Camera, world Hitable, lighthitable Hitable, backgroundFunc BackgroundFunc) Scene

type Texture

type Texture interface {
	GetValue(uvCoords mgl64.Vec2, p mgl64.Vec3) ColorVector
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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