Documentation ¶
Overview ¶
Package grbt contains code for a ray tracer in beam.
Index ¶
- Constants
- func BeamTracer(position Vec, img ImageConfig, word, dir string) *beam.Pipeline
- func OrdinaryTracer(origin Vec, cfg ImageConfig, word, dir string)
- func OutputPath(dir, word string, samples int) string
- func RandomVal() float64
- func RayMarching(origin, direction Vec, scene *Scene) (hitType HitType, hitPos, hitNorm Vec)
- func ValidateWord(word string) error
- type Arc
- type ArcType
- type CombinePixelsFn
- type Dir
- type Float
- type HitType
- type ImageConfig
- type Letter
- type MakeImageFn
- type Model
- type Obj
- type Pixel
- type PixelColour
- type PositionedModel
- type Room
- type Scene
- type Sphere
- type TraceFn
- type Vec
Constants ¶
const ( ArcCircle = ArcType(iota) ArcSemi ArcQuarter ArcThreeQuarter )
Arcs of varying completion
const ( DirRight = Dir(iota) DirDown DirLeft DirUp )
Directions
const ( HitNone = HitType(iota) HitLetterBlack HitLetterWhite HitLetterRed HitLetterGreen HitLetterBlue HitLetterYellow HitGopherBlue HitGopherTeal HitWall HitSun HitAABB )
HitTypes for known materials.
Variables ¶
This section is empty.
Functions ¶
func BeamTracer ¶
func BeamTracer(position Vec, img ImageConfig, word, dir string) *beam.Pipeline
BeamTracer runs the ray tracer as a Apache Beam Pipeline on the runner of choice.
func OrdinaryTracer ¶
func OrdinaryTracer(origin Vec, cfg ImageConfig, word, dir string)
OrdinaryTracer is a standard implementation of a ray tracer for validation and performance comparison purposes.
func OutputPath ¶
OutputPath generates a png file path based on the given directory, path and number of samples.
func RayMarching ¶
RayMarching performs signed sphere marching Returns hitType and updated hit positions & normal.
func ValidateWord ¶
ValidateWord checks that the word can be printed by the letter models.
Types ¶
type CombinePixelsFn ¶
type CombinePixelsFn struct {
SamplesCount int
}
CombinePixelsFn combines the contributions from multiple pixels.
func (*CombinePixelsFn) AddInput ¶
func (fn *CombinePixelsFn) AddInput(ctx context.Context, a, b Vec) Vec
AddInput sums together the colour contributions for a pixel. Typically on the lifted side of a CombineFn
func (*CombinePixelsFn) ExtractOutput ¶
func (fn *CombinePixelsFn) ExtractOutput(colour Vec) Vec
ExtractOutput does the Reinhard tone mapping for this pixel.
func (*CombinePixelsFn) MergeAccumulators ¶
func (fn *CombinePixelsFn) MergeAccumulators(ctx context.Context, a, b Vec) Vec
MergeAccumulators sums together the colour contributions for a pixel.
type Float ¶
type Float float64
Float is a convenience type incase I decide to change the precision later.
func BoxTest ¶
BoxTest is the Rectangle CSG equation. Returns minimum signed distance from space carved by lowerLeft vertex and opposite rectangle vertex upperRight.
func SphereTest ¶
SphereTest is the Sphere CSG equation.
type ImageConfig ¶
ImageConfig contains properties of the generated image, used to generate initial rays.
type Letter ¶
type Letter struct { Char string Lines [][2][2]Float Curves []Arc // contains filtered or unexported fields }
Letter models character with CSG. Separate Positions I think. That will get subtracted from the ray's position.
func (*Letter) Initialize ¶
func (m *Letter) Initialize()
Initialize sets the bounding box for the letter.
type MakeImageFn ¶
MakeImageFn writes the image to wherever.
func (*MakeImageFn) ProcessElement ¶
func (f *MakeImageFn) ProcessElement(ctx context.Context, _ beam.T, iter func(*PixelColour) bool) (bool, error)
ProcessElement iterates over all the functions and writes Writes the file to the designated spot.
type Model ¶
type Model interface { // Initialize does any necessary precomputations on the model // eg. Handle AABBs? How do we propagate those up the scene graph? Initialize() // Query calculates the distance to the model from the position. Query(position Vec) (distance Float, material HitType) }
Model is where we're going to hang all the geometry stuff.
type Obj ¶
Obj represents a single object set of connected polygons.
func (*Obj) Initialize ¶
func (m *Obj) Initialize()
Initialize precomputes information from the data.
type Pixel ¶
type Pixel struct {
X, Y int
}
Pixel is an x,y coordinate in an image. Used as a key for grouping sample rays back together.
type PixelColour ¶
PixelColour combines a pixel with its colour.
func ToPixelColour ¶
func ToPixelColour(k Pixel, colour Vec) PixelColour
ToPixelColour combines pixels with it's colour.
type PositionedModel ¶
PositionedModel is a model with a "global" position with the scene. This is where rotations etc need to be handled to translate from world space to model space.
type Scene ¶
type Scene struct { Ms []*PositionedModel // contains filtered or unexported fields }
Scene is the what is being Ray Traced.
func (*Scene) Initialize ¶
func (s *Scene) Initialize()
Initialize recursively initializes the rest of the scene.
type Sphere ¶
Sphere models a sphere.
func (*Sphere) Initialize ¶
func (m *Sphere) Initialize()
Initialize provides a default material if needed.
type TraceFn ¶
type TraceFn struct { // TODO retype Vec to Position or something. // requires redoing doing all the math for type safety. Position Vec Bounces int64 // TODO move this to a side input Word string // contains filtered or unexported fields }
TraceFn creates rays from the pixels.
func (*TraceFn) ProcessElement ¶
ProcessElement actualy traces the scene of the image and returns the colour contribution of this sample. TODO retype the returned thing to a colour, instead of a vec.