Documentation ¶
Overview ¶
Package hittable provides objects that are hittable by rays shot by the ray tracer. Some of these hittable objects are containers for other objects Some others are used to translate or rotate other objects
Index ¶
- func NewHittablePdf(objects *HittableList, origin geo.Vec3) pdf.Pdf
- func SortTrianglesByCenter(list []Triangle, center float64, axis int) int
- type Hittable
- func NewBoundingVolumeHierarchy(list []Triangle) Hittable
- func NewBox(a geo.Vec3, b geo.Vec3, mat material.Material) Hittable
- func NewConstantMedium(boundary Hittable, density float64, color geo.Vec3) Hittable
- func NewMotionBlur(blurredHittable Hittable, blurDirection geo.Vec3) Hittable
- func NewObjModel(path, filename string, scale float64) (Hittable, error)
- func NewObjModelWithDefaultMaterial(path, filename string, scale float64, defaultMaterial material.Material) (Hittable, error)
- func NewQuad(Q geo.Vec3, u geo.Vec3, v geo.Vec3, mat material.Material) Hittable
- func NewRotationY(object Hittable, angle float64) Hittable
- func NewSphere(center geo.Vec3, radius float64, mat material.Material) Hittable
- func NewTranslation(object Hittable, offset geo.Vec3) Hittable
- type HittableList
- func (hl *HittableList) Add(h Hittable)
- func (hl *HittableList) BoundingBox() aabb
- func (hl *HittableList) Hit(r geo.Ray, rayLength util.Interval) (bool, *material.HitRecord)
- func (hl *HittableList) IsLight() bool
- func (hl *HittableList) List() []Hittable
- func (hl *HittableList) PdfValue(origin, direction geo.Vec3) float64
- func (hl *HittableList) RandomDirection(origin geo.Vec3) geo.Vec3
- type HittablePdf
- type NonPdfLightHittable
- type PdfLightHittable
- type Triangle
- func (t Triangle) BoundingBox() aabb
- func (t Triangle) Center(axis int) float64
- func (t Triangle) Hit(r geo.Ray, rayLength util.Interval) (bool, *material.HitRecord)
- func (t Triangle) IsLight() bool
- func (t Triangle) PdfValue(origin, direction geo.Vec3) float64
- func (t Triangle) RandomDirection(origin geo.Vec3) geo.Vec3
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHittablePdf ¶ added in v0.0.7
func NewHittablePdf(objects *HittableList, origin geo.Vec3) pdf.Pdf
NewHittablePdf creates a new instance of HittablePdf
Types ¶
type Hittable ¶
type Hittable interface { PdfLightHittable Hit(r geo.Ray, rayLength util.Interval) (bool, *material.HitRecord) BoundingBox() aabb IsLight() bool }
Hittable is the common interface for all objects in the ray tracing scene that can be hit by rays
func NewBoundingVolumeHierarchy ¶
NewBoundingVolumeHierarchy creates a new hittable object from the given hittable list The bounding Volume Hierarchy sorts the hittables in a binary tree where each node has a bounding box. This is to optimize the ray intersection search when having many hittable objects.
func NewConstantMedium ¶
NewConstantMedium creates a fog type hittable object where rays not only scatter at the edge of the object, but at random points inside the object The material of the boundary hittable is not used and can be nil
func NewMotionBlur ¶
NewMotionBlur creates a new hittable object that adds linear interpolated translation to its hittable based on the time of the ray. This gives the appearance of the object moving.
func NewObjModel ¶ added in v0.3.0
NewObjModel reads a Wavefront .obj file and creates a bvh containing all triangles. It also read materials from the referred .mat file. Support for colored and textured lambertian materials.
func NewObjModelWithDefaultMaterial ¶ added in v0.3.1
func NewObjModelWithDefaultMaterial(path, filename string, scale float64, defaultMaterial material.Material) (Hittable, error)
NewObjModelWithDefaultMaterial reads a Wavefront .obj file and creates a bvh containing all triangles. It also read materials from the referred .mat file. Support for colored and textured lambertian materials. Applies supplied default material if none in model
func NewRotationY ¶
NewRotationY creates a hittable object that rotates the given hittable around the Y axis
type HittableList ¶
type HittableList struct {
// contains filtered or unexported fields
}
HittableList is a special type of hittable that is a container for a list of other hittable objects. Used to be able to have many objects in a scene
func NewHittableList ¶
func NewHittableList() HittableList
NewHittableList creates new empty HittableList
func (*HittableList) Add ¶
func (hl *HittableList) Add(h Hittable)
Add adds a new hittable object to this HittableList
func (*HittableList) BoundingBox ¶
func (hl *HittableList) BoundingBox() aabb
BoundingBox returns the bounding box that encapsulates all hittables in the list
func (*HittableList) Hit ¶
Hit Checks if the given ray hits any object in this list. And if so, returns the properties of that ray hit
func (*HittableList) IsLight ¶ added in v0.0.7
func (hl *HittableList) IsLight() bool
IsLight returns if a hittable list itself is a light, which it is not
func (*HittableList) List ¶ added in v0.0.7
func (hl *HittableList) List() []Hittable
List returns the current slice of hittables
func (*HittableList) PdfValue ¶ added in v0.0.7
func (hl *HittableList) PdfValue(origin, direction geo.Vec3) float64
PdfValue generates a medium pdf value for all hittables in list given an origin and a direction
func (*HittableList) RandomDirection ¶ added in v0.0.7
func (hl *HittableList) RandomDirection(origin geo.Vec3) geo.Vec3
RandomDirection generates a random direction for a random hittable in the list
type HittablePdf ¶ added in v0.0.7
type HittablePdf struct {
// contains filtered or unexported fields
}
HittablePdf is a wrapper for generating pdfs for a list of hittables
func (HittablePdf) Generate ¶ added in v0.0.7
func (p HittablePdf) Generate() geo.Vec3
Generate implements pdf.Pdf
type NonPdfLightHittable ¶ added in v0.3.7
type NonPdfLightHittable struct{}
NonPdfLightHittable is used by hittables that never uses pdfs directly Will panic hittable is a light and other hittable has pdf generating material
func (NonPdfLightHittable) PdfValue ¶ added in v0.3.7
func (h NonPdfLightHittable) PdfValue(origin, direction geo.Vec3) float64
PdfValue panics if invoked
func (NonPdfLightHittable) RandomDirection ¶ added in v0.3.7
func (h NonPdfLightHittable) RandomDirection(origin geo.Vec3) geo.Vec3
RandomDirection panics if invoked
type PdfLightHittable ¶ added in v0.3.7
type PdfLightHittable interface { PdfValue(origin, direction geo.Vec3) float64 RandomDirection(origin geo.Vec3) geo.Vec3 }
PdfLightHittable has methods used when other hittables have pdf scattering materials. This should be implemented by hittables that can have light materials.
type Triangle ¶ added in v1.0.0
type Triangle struct {
// contains filtered or unexported fields
}
func NewTriangle ¶ added in v0.3.0
func NewTriangleWithTexCoords ¶ added in v0.3.0
func NewTriangleWithTexCoords(v0, v1, v2 geo.Vec3, tu0, tv0, tu1, tv1, tu2, tv2 float64, mat material.Material) Triangle
NewTriangle creates a new triangle flat hittable object A counter clockwise winding is expected
func (Triangle) BoundingBox ¶ added in v1.0.0
func (t Triangle) BoundingBox() aabb