engine

package
v0.0.0-...-5ed2699 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dielectric

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

func (Dielectric) MarshalJSON

func (die Dielectric) MarshalJSON() ([]byte, error)

type HitRecord

type HitRecord struct {
	T        float64         // which t generated the hit
	P        geometry.Point3 // which point when hit
	Normal   geometry.Vec3   // normal at that point
	Material Material        // the material associated to this record
}

type Hittable

type Hittable interface {
	Hit(r *geometry.Ray, interval *utils.Interval) (bool, *HitRecord)
}

Hittable defines the interface of objects that can be hit by a ray

type HittableList

type HittableList []Hittable

HittableList defines a simple list of hittable

func (HittableList) Hit

func (hl HittableList) Hit(r *geometry.Ray, interval *utils.Interval) (bool, *HitRecord)

Hit defines the method for a list of hittables: will return the one closest

type Lambertian

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

func (Lambertian) MarshalJSON

func (mat Lambertian) MarshalJSON() ([]byte, error)

type Material

type Material interface {
	// contains filtered or unexported methods
}

Material defines how a material scatter light

func UnmarshalMaterial

func UnmarshalMaterial(data json.RawMessage) (Material, error)

type Metal

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

func (Metal) MarshalJSON

func (mat Metal) MarshalJSON() ([]byte, error)

type Pixels

type Pixels []uint32

Pixels represents the array of pixels (in packed RGB value) to Render and/or save

type Scene

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

Scene represents the scene to Render.

func NewScene

func NewScene(width, height, raysPerPixel int, camera camera.Camera, world Hittable) *Scene

func (*Scene) Render

func (scene *Scene) Render(parallelCount int) (Pixels, chan struct{})

Render is the main method of a scene. It is non-blocking and returns right away with the array of pixels that will be computed asynchronously and a channel to indicate when the processing is complete. Note that no synchronization is required on the array of pixels since it is an array of 32 bits values. The image (width x height) will be split in lines each one processed in a separate goroutine (parallelCount of them).

type Sphere

type Sphere struct {
	Center   geometry.Point3 `json:"center"`
	Radius   float64         `json:"radius"`
	Material Material        `json:"material"`
}

func (Sphere) Hit

func (s Sphere) Hit(r *geometry.Ray, interval *utils.Interval) (bool, *HitRecord)

Hit implements the Hit interface for a Sphere

func (*Sphere) UnmarshalJSON

func (s *Sphere) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals JSON data into a Sphere object

type World

type World struct {
	Camera  camera.Camera `json:"camera"`
	Objects HittableList  `json:"objects"`
}

func (*World) UnmarshalJSON

func (w *World) UnmarshalJSON(data []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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