trace

package
v0.0.0-...-3626a0a Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2015 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Trace

func Trace(options *options.Options, gridSize int) *image.NRGBA

Trace renders an image according to the given options. It renders the image in chuncks of the given size in parallel.

Types

type Camera

type Camera struct {
	Position mgl64.Vec3
	ViewDir  mgl64.Vec3

	UseDof         bool
	FocalDistance  float64
	ApertureRadius float64
	// contains filtered or unexported fields
}

Camera is a viewpoint into a scene and is able to generate Camera rays.

func NewCamera

func NewCamera(opts *options.Camera, aspectRatio float64) *Camera

NewCamera initializes a Camera based on the options and returns it.

func (*Camera) DofRayThrough

func (c *Camera) DofRayThrough(center, r *ray.Ray)

DofRayThrough takes a center ray (which is not midified) and modifies r to be a randomized ray, according do depth of field settings, whose origin is slightly off the center but

func (*Camera) RayThrough

func (c *Camera) RayThrough(nx, ny float64, r *ray.Ray)

RayThrough takes normalized window coordinates and returns the ray that goes through that point starting from the camera.

type Coeff

type Coeff struct {
	Constant  float64
	Linear    float64
	Quadratic float64
}

type Light

type Light interface {
	// Attenuation(scene *Scene, point mgl64.Vec3) Color64
	// Direction(from mgl64.Vec3) mgl64.Vec3
	GenIllumMap(*Scene)
}

func NewLight

func NewLight(opts *options.Light) (Light, error)

type Result

type Result struct {
	Color    color64.Color64
	RayCount [ray.NumTypes]int
}

Result contains the results of tracing a ray into a scene. It includes the color and the number of each type of ray that was produced.

type Scene

type Scene struct {
	*options.Options
	Camera    *Camera
	BgColor   color64.Color64
	BgTex     *texture.Texture
	Lights    []Light
	Materials map[string]*material.Material
	// contains filtered or unexported fields
}

Scene represents the scene and all data needed to render it.

func NewScene

func NewScene(options *options.Options) *Scene

NewScene creates and returns a new Scene from the given options.

func (*Scene) BackgroundColor

func (s *Scene) BackgroundColor(r *ray.Ray) color64.Color64

BackgroundColor returns the color a ray returns when it hits no objects.

func (*Scene) ColorAt

func (s *Scene) ColorAt(x, y int) color.NRGBA

ColorAt returns the color of the pixel at (x, y).

func (*Scene) TraceDof

func (s *Scene) TraceDof(nx, ny float64, rayCounts *ray.Counts) color64.Color64

TraceDof handles depth of field logic if the camera is configured to use it, otherwise it traces a normal ray though the camera and the given normalized window coordinates.

func (*Scene) TraceIllumRay

func (s *Scene) TraceIllumRay(r *ray.Ray, color color64.Color64, depth int)

TraceIllumRay traces a ray for the purpose of generating illumination maps.

func (*Scene) TraceRay

func (s *Scene) TraceRay(r *ray.Ray, depth int, contribution float64, rayCounts *ray.Counts) color64.Color64

TraceRay sends a ray into the scene and returns the color it finds.

type Spot

type Spot struct {
	Color     color64.Color64
	Position  mgl64.Vec3
	Direction mgl64.Vec3
	IllumMap  bool
	Coeff
	Angle     float64
	DropOff   float64
	FadeAngle float64
}

func (*Spot) GenIllumMap

func (s *Spot) GenIllumMap(scene *Scene)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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