goray

package module
v0.0.0-...-ec9fd1c Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2012 License: GPL-3.0 Imports: 14 Imported by: 0

README

*********
  goray
*********

goray is very much beta quality software and not ready for production.  Many
features are missing, some things may not work right, and the behavior of the
program is not well documented.

That said, you must have `Go`_ 1.0.1 installed to build goray.

Download and install goray with::

    go get -u bitbucket.org/zombiezen/goray/goray

To run goray, provide a scene description file (a YAML file) as the sole
argument.  By default, goray will render to a file called ``goray.png`` in the
current directory.  For example::

    goray demos/suzanne.yaml

For further help::

    goray -help

.. _Go: http://golang.org/

License
=========

| Copyright © 2011 Ross Light
| Based on YafaRay: Copyright © 2005 Mathias Wein, Alejandro Conty, and Alfredo de Greef
| jQuery: Copyright © 2011 John Resig

goray comes with ABSOLUTELY NO WARRANTY.  goray is free software, and you are
welcome to redistribute it under the conditions of the GNU Lesser General
Public License v3, or (at your option) any later version.

jQuery License
----------------

Copyright © 2011 John Resig, http://jquery.com/

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation

Index

Constants

View Source
const (
	LightTypeDiracDir = 1 << iota // A light with TypeDiracDir has a Dirac delta distribution
	LightTypeSingular

	LightTypeNone = 0
)

Light types

Variables

This section is empty.

Functions

func BlockIntegrate

func BlockIntegrate(s *Scene, in Integrator, log log.Logger) <-chan Fragment

BlockIntegrate integrates an image in small batches.

func SimpleIntegrate

func SimpleIntegrate(s *Scene, in Integrator, log log.Logger) <-chan Fragment

SimpleIntegrate integrates an image one pixel at a time.

func WorkerIntegrate

func WorkerIntegrate(s *Scene, in Integrator, log log.Logger) <-chan Fragment

WorkerIntegrate integrates an image using a set number of jobs.

Types

type BSDF

type BSDF uint

BSDF holds bidirectional scattering distribution function flags.

const (
	BSDFSpecular BSDF = 1 << iota
	BSDFGlossy
	BSDFDiffuse
	BSDFDispersive
	BSDFReflect
	BSDFTransmit
	BSDFFilter
	BSDFEmit
	BSDFVolumetric

	BSDFNone        = 0
	BSDFAllSpecular = BSDFSpecular | BSDFReflect | BSDFTransmit
	BSDFAll         = BSDFSpecular | BSDFGlossy | BSDFDiffuse | BSDFDispersive | BSDFReflect | BSDFTransmit | BSDFFilter
)

These constants specify material attributes. For more information, see http://en.wikipedia.org/wiki/Bidirectional_scattering_distribution_function

type Background

type Background interface {
	// Color returns the background color for a given ray.
	Color(r Ray, state *RenderState, filtered bool) color.Color

	// Light returns the light source representing background lighting.
	// This may be nil if the background should only be sampled from BSDFs.
	Light() Light
}

Background is an interface for a rendering background.

type Camera

type Camera interface {
	// ShootRay calculates the initial ray used for computing a fragment of the
	// output.  U and V are sample coordinates that are only calculated if
	// SampleLens returns true.
	ShootRay(x, y, u, v float64) (Ray, float64)

	// ResolutionX returns the number of fragments wide that the camera is.
	ResolutionX() int

	// ResolutionY returns the number of fragments high that the camera is.
	ResolutionY() int

	// Project calculates the projection of a ray onto the fragment plane.
	Project(wo Ray, lu, lv *float64) (pdf float64, changed bool)

	// SampleLens returns whether the lens needs to be sampled using the u and v
	// parameters of ShootRay.  This is useful for DOF-like effects.  When this
	// returns false, no lens samples need to be computed.
	SampleLens() bool
}

Camera is a viewpoint of a scene.

type ClipPrimitive

type ClipPrimitive interface {
	Primitive
	Clipper
}

type Clipper

type Clipper interface {
	// Clip calculates the overlapping bounding box of a given bounding box and the primitive.
	// If the bounding box returned is nil, then no such bound exists.
	Clip(bound bound.Bound, axis vecutil.Axis, lower bool, oldData interface{}) (clipped bound.Bound, newData interface{})
}

type Collision

type Collision struct {
	Primitive Primitive
	Ray       Ray
	RayDepth  float64
	UserData  interface{}
}

Collision stores information about a ray intersection.

func (Collision) Hit

func (c Collision) Hit() bool

Hit returns whether the ray intersection succeeded. If this method returns false, then the rest of the structure is meaningless.

func (Collision) Point

func (c Collision) Point() vec64.Vector

Point returns the point in world coordinates where the ray intersected.

func (Collision) Surface

func (c Collision) Surface() (sp SurfacePoint)

Surface returns the surface point where the ray intersected.

type DifferentialRay

type DifferentialRay struct {
	Ray
	FromX, FromY vec64.Vector
	DirX, DirY   vec64.Vector
}

DifferentialRay stores additional information about a ray for use in surface intersections. For an explanation, see http://www.opticalres.com/white%20papers/DifferentialRayTracing.pdf

func (DifferentialRay) String

func (r DifferentialRay) String() string

type Differentials

type Differentials struct {
	X, Y  vec64.Vector
	Point SurfacePoint
}

Differentials computes and stores data for surface intersections for differential rays. For more information, see http://www.opticalres.com/white%20papers/DifferentialRayTracing.pdf

func NewDifferentials

func NewDifferentials(p SurfacePoint, r *DifferentialRay) Differentials

NewDifferentials creates a new Differentials struct.

func (Differentials) ProjectedPixelArea

func (d Differentials) ProjectedPixelArea() float64

func (Differentials) ReflectRay

func (d Differentials) ReflectRay(in, out *DifferentialRay)

ReflectRay computes differentials for a scattered ray. For an explanation, see: http://en.wikipedia.org/wiki/Specular_reflection

func (Differentials) RefractRay

func (d Differentials) RefractRay(in, out *DifferentialRay, ior float64)

RefractRay computes differentials for a scattered ray. For an explanation, see: http://en.wikipedia.org/wiki/Snell's_law#Vector_form

type DiracLight

type DiracLight interface {
	Light

	// Illuminate computes the amount of light to add to a given surface point.
	Illuminate(sp SurfacePoint, wi *Ray) (col color.Color, ok bool)
}

type EmitMaterial

type EmitMaterial interface {
	Material
	// Emit returns the amount of light to contribute.
	Emit(state *RenderState, sp SurfacePoint, wo vec64.Vector) color.Color
}

EmitMaterial defines a material that contributes light to the scene.

type Fragment

type Fragment struct {
	Color color_.AlphaColor
	X, Y  int
}

Fragment stores a single element of an image.

func RenderPixel

func RenderPixel(s *Scene, i Integrator, x, y int) Fragment

RenderPixel creates a fragment for a position in the image.

type GatherResult

type GatherResult struct {
	Photon   Photon
	Distance float64
}

type Image

type Image struct {
	Width, Height int
	Pix           []color_.RGBA
}

Image stores a two-dimensional array of colors. It implements the image.Image interface, so you can use it directly with the standard library.

func NewGoImage

func NewGoImage(oldImage image.Image) (newImage *Image)

NewGoImage creates a new image based on an image from the standard Go library.

func NewImage

func NewImage(w, h int) (img *Image)

NewImage creates a new, blank image with the given width and height.

func Render

func Render(s *Scene, i Integrator, log log.Logger) (img *Image)

Render is an easy way of creating an image from a scene.

Render will update the scene, create a new image, and then use one of the integration functions to write to the image.

func (*Image) Acquire

func (i *Image) Acquire(ch <-chan Fragment)

Acquire receives fragments from a channel until the channel is closed.

func (*Image) At

func (i *Image) At(x, y int) color.Color

func (*Image) Bounds

func (i *Image) Bounds() image.Rectangle

func (*Image) Clear

func (i *Image) Clear(clearColor color_.AlphaColor)

Clear sets all of the pixels in the image to a given color.

func (*Image) ColorModel

func (i *Image) ColorModel() color.Model

func (*Image) Pixel

func (i *Image) Pixel(x, y int) color_.RGBA

Pixel returns the color.RGBA at a position. If you are iterating over the pixels, use the Pix slice directly.

type Integrator

type Integrator interface {
	Preprocess(scene *Scene)
	Integrate(scene *Scene, state *RenderState, r DifferentialRay) color.AlphaColor
}

An Integrator renders rays.

type Intersecter

type Intersecter interface {
	// Intersect determines the goray that a goray collides with.
	Intersect(r Ray, dist float64) Collision

	// Shadowed checks whether a goray collides with any primitives (for shadow-detection).
	Shadowed(r Ray, dist float64) bool

	// TransparentShadow computes the color of a transparent shadow after being
	// filtered by the objects in the scene.  The resulting color can be
	// multiplied by the light color to determine the color of the shadow.  The
	// hit return value is set when an opaque goray is encountered or the
	// maximum depth is exceeded.
	TransparentShadow(state *RenderState, r Ray, maxDepth int, dist float64) (filt color.Color, hit bool)

	// Bound returns a bounding box that contains all of the primitives that the intersecter knows about.
	Bound() bound.Bound
}

Intersecter defines a type that can detect goray collisions.

For most cases, this will involve an algorithm that partitions the scene to make these operations faster.

type IntersecterBuilder

type IntersecterBuilder func([]Primitive, log.Logger) Intersecter

type Light

type Light interface {
	// LightFlags returns the type of light the light is.
	LightFlags() uint

	// SetScene sets up a light for use with a scene.
	SetScene(scene *Scene)

	// NumSamples returns the preferred number of samples for direct lighting.
	NumSamples() int

	// TotalEnergy returns the light's color energy emitted during a frame.
	TotalEnergy() color.Color

	// EmitPhoton computes the values necessary for a photon.
	EmitPhoton(s1, s2, s3, s4 float64) (color.Color, Ray, float64)

	// EmitSample creates a light emission sample.  It's more suited to bidirectional methods than EmitPhoton.
	EmitSample(s *LightSample) (vec64.Vector, color.Color)

	// EmitPdf returns the PDFs for sampling with EmitSample.
	EmitPdf(sp SurfacePoint, wo vec64.Vector) (areaPdf, dirPdf, cosWo float64)

	// CanIlluminate returns whether the light can illuminate a certain point.
	CanIlluminate(pt vec64.Vector) bool

	// IlluminateSample samples the illumination at a given point.
	//
	// The Sample passed in will be filled with the proper sample values.
	// The returned ray will be the ray that casted the light.
	IlluminateSample(sp SurfacePoint, wi *Ray, s *LightSample) (illuminated bool)

	// IlluminatePdf returns the PDF for sampling with IllumSample.
	IlluminatePdf(sp, spLight SurfacePoint) float64
}

Light is an entity that illuminates a scene.

type LightIntersecter

type LightIntersecter interface {
	// Intersect intersects the light source with a ray, giving back the distance, the energy, and 1/PDF.
	Intersect(r Ray) (dist float64, col color.Color, ipdf float64, ok bool)
}

type LightSample

type LightSample struct {
	S1, S2  float64      // 2D sample value for choosing a surface point on the light.
	S3, S4  float64      // 2D sample value for choosing an outgoing direction on the light (EmitSample)
	Pdf     float64      // "Standard" directional PDF from illuminated surface point for MC integration of direct lighting (IllumSample)
	DirPdf  float64      // Probability density for generating this sample direction (EmitSample)
	AreaPdf float64      // Probability density for generating this sample point on light surface (EmitSample)
	Color   color.Color  // Color of the generated sample
	Flags   uint         // Flags of the sampled light source
	Point   SurfacePoint // Surface point on the light source.  This may only be complete enough to call other light methods with it!
}

LightSample holds data for a light sample.

type Material

type Material interface {
	// InitBSDF initializes the BSDF of a material.  You must call this with
	// the current surface point first before any other methods (except
	// Transparency).
	InitBSDF(state *RenderState, sp SurfacePoint) BSDF

	// MaterialFlags returns the attributes of a material.
	MaterialFlags() BSDF

	// Eval evaluates the BSDF for the given components.
	Eval(state *RenderState, sp SurfacePoint, wo, wl vec64.Vector, types BSDF) color.Color

	// Sample takes a sample from the BSDF.  The sample pointer will be filled in with the computed values.
	Sample(state *RenderState, sp SurfacePoint, wo vec64.Vector, s *MaterialSample) (color.Color, vec64.Vector)

	// Pdf returns the PDF for sampling the BSDF.
	Pdf(state *RenderState, sp SurfacePoint, wo, wi vec64.Vector, bsdfs BSDF) float64

	// Specular evaluates the specular components of a material for a given direction.
	Specular(state *RenderState, sp SurfacePoint, wo vec64.Vector) (reflect, refract bool, dir [2]vec64.Vector, col [2]color.Color)

	// Reflectivity returns the overal reflectivity of a material.
	Reflectivity(state *RenderState, sp SurfacePoint, flags BSDF) color.Color

	// Alpha returns the alpha value of a material.
	Alpha(state *RenderState, sp SurfacePoint, wo vec64.Vector) float64

	// ScatterPhoton performs photon mapping.  The sample pointer will be filled in with the computed values.
	ScatterPhoton(state *RenderState, sp SurfacePoint, wi vec64.Vector, s *PhotonSample) (wo vec64.Vector, scattered bool)
}

Material defines the behavior of the surface properties of an object.

type MaterialSample

type MaterialSample struct {
	S1, S2              float64
	Pdf                 float64
	Flags, SampledFlags BSDF
	Reverse             bool
	PdfBack             float64
	ColorBack           color.Color
}

MaterialSample is a sample of a material on a surface.

func NewMaterialSample

func NewMaterialSample(s1, s2 float64) (s MaterialSample)

type Mesh

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

A Mesh is a collection of triangles. The basic workflow for making a working mesh is: create the mesh, set the mesh's data, then add the triangles.

func NewMesh

func NewMesh(ntris int, hasOrco bool) (mesh *Mesh)

NewMesh creates an empty mesh.

func (*Mesh) AddTriangle

func (mesh *Mesh) AddTriangle(t *Triangle)

AddTriangle adds a face to the mesh.

func (*Mesh) Primitives

func (mesh *Mesh) Primitives() (prims []Primitive)

func (*Mesh) SetData

func (mesh *Mesh) SetData(vertices, normals []vec64.Vector, uvs []UV)

SetData changes the mesh's data.

For memory efficiency, the actual data for a mesh isn't stored in the triangles; the data is stored in the mesh. The triangles simply contain indices that point to parts of the various arrays kept by the mesh. Because most meshes have connected faces, this means that each vertex is stored once, instead of three times (much better!).

Both normals and uvs are optional. If you don't want to enable per-vertex normals or UV coordinates, then pass nil for the corresponding parameter. Any triangles that don't have per-vertex normals set will use the computed normal.

func (*Mesh) SetLight

func (mesh *Mesh) SetLight(l Light)

func (mesh *Mesh) EvalVmap(sp surface.Point, id uint, val []float) int { return 0 }

func (*Mesh) SetVisible

func (mesh *Mesh) SetVisible(v bool)

func (*Mesh) Visible

func (mesh *Mesh) Visible() bool

type Object3D

type Object3D interface {
	// Primitives returns all of the primitives for this object.
	Primitives() []Primitive

	// Visible indicates whether the object is shown in the scene.
	Visible() bool
}

Object3D is a collection of primitives.

type ObjectID

type ObjectID uint

type Photon

type Photon struct {
	Position  vec64.Vector
	Direction vec64.Vector
	Color     color.Color
}

type PhotonMap

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

func NewMap

func NewMap() *PhotonMap

func (*PhotonMap) AddPhoton

func (pm *PhotonMap) AddPhoton(p Photon)

func (*PhotonMap) Clear

func (pm *PhotonMap) Clear()

func (*PhotonMap) Dimension

func (pm *PhotonMap) Dimension(i int, axis vecutil.Axis) (float64, float64)

func (*PhotonMap) FindNearest

func (pm *PhotonMap) FindNearest(p, n vec64.Vector, dist float64) (nearest Photon)

func (*PhotonMap) Gather

func (pm *PhotonMap) Gather(p vec64.Vector, nLookup int, maxDist float64) []GatherResult

func (*PhotonMap) Len

func (pm *PhotonMap) Len() int

func (*PhotonMap) NumPaths

func (pm *PhotonMap) NumPaths() int

func (*PhotonMap) Ready

func (pm *PhotonMap) Ready() bool

func (*PhotonMap) SetNumPaths

func (pm *PhotonMap) SetNumPaths(np int)

func (*PhotonMap) Update

func (pm *PhotonMap) Update()

type PhotonSample

type PhotonSample struct {
	MaterialSample
	S3        float64
	LastColor color.Color // LastColor is the photon color from the last scattering.
	Alpha     color.Color // Alpha is the filter color between the last scattering and this collision.
	Color     color.Color // Color is the new color after scattering.  LastColor will use this value for the next scatter.
}

PhotonSample is a sample of a material on a surface, along with photon information.

func NewPhotonSample

func NewPhotonSample(s1, s2, s3 float64, flags BSDF, lCol color.Color) (s PhotonSample)

type Primitive

type Primitive interface {
	// Bound returns the bounding box in global (world) coordinates.
	Bound() bound.Bound

	// IntersectsBound returns whether a bounding box intersects the primitive.
	// This can be used to implement more precise partitioning.
	IntersectsBound(bound.Bound) bool

	// Intersect checks whether a ray collides with the primitive.
	// This should not skip intersections outside of [TMin, TMax].
	Intersect(r Ray) Collision

	// Surface obtains information about a point on the primitive's surface.
	//
	// You can only get the surface point by ray casting to it.  Admittedly, this is slightly inflexible,
	// but it's the only use-case for this method.  The advantage is that Intersect can pass any extra data
	// that it could need to efficiently implement GetSurface in the Collision struct.
	Surface(Collision) SurfacePoint

	// Material returns the material associated with this primitive.
	Material() Material
}

Primitive defines a basic 3D entity in a scene.

type PrimitiveObject

type PrimitiveObject struct {
	Primitive Primitive
}

PrimitiveObject is a wrapper type that allows a single primitive to act as an object.

func (PrimitiveObject) Primitives

func (o PrimitiveObject) Primitives() []Primitive

func (PrimitiveObject) Visible

func (o PrimitiveObject) Visible() bool

type Ray

type Ray struct {
	From       vec64.Vector
	Dir        vec64.Vector
	TMin, TMax float64
	Time       float64
}

Ray defines the path of light.

func (Ray) String

func (r Ray) String() string

type RenderState

type RenderState struct {
	RayLevel       int
	Depth          float64
	Contribution   float64
	SkipElement    interface{}
	CurrentPass    int
	PixelSample    int
	RayDivision    int
	RayOffset      int
	Dc1, Dc2       float64
	Traveled       float64
	PixelNumber    int
	SamplingOffset uint
	ScreenPos      vec64.Vector
	Chromatic      bool
	IncludeLights  bool
	WaveLength     float64
	Time           float64
	MaterialData   interface{}
}

RenderState stores information concerning the current rendering state.

func (*RenderState) Init

func (st *RenderState) Init()

Init initializes the state.

func (*RenderState) SetDefaults

func (st *RenderState) SetDefaults()

SetDefaults changes some values to their initial values.

type Samplable

type Samplable interface {
	// EnableSampling tries to enable sampling (may require additional memory and preprocessing time).
	EnableSampling() bool

	// Sample takes a sample of the object's surface.
	Sample(s1, s2 float64) (p, n vec64.Vector)
}

Samplable defines an interface for sampling a surface.

type SamplableObject3D

type SamplableObject3D interface {
	Object3D
	Samplable
}

SamplableObject3D is the set of three-dimensional objects that can sample their surfaces.

type Scene

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

Scene stores all of the entities that define an environment to render. Scene also functions as a high-level API for goray: once you have created a scene, you can create geometry, add entities, and render an image.

func NewScene

func NewScene(ib IntersecterBuilder, l log.Logger) (s *Scene)

NewScene creates a new scene.

func (*Scene) AddLight

func (s *Scene) AddLight(l Light) (err error)

AddLight adds a light to the scene.

func (*Scene) AddMaterial

func (s *Scene) AddMaterial(name string, m Material) (err error)

AddMaterial adds a material to the scene.

func (*Scene) AddObject

func (s *Scene) AddObject(obj Object3D) (id ObjectID, err error)

AddObject adds a three-dimensional object to the scene.

func (*Scene) AddVolumeRegion

func (s *Scene) AddVolumeRegion(vr VolumeRegion)

AddVolumeRegion adds a volumetric effect to the scene.

func (*Scene) Background

func (s *Scene) Background() Background

Background returns the scene's current background.

func (*Scene) Bound

func (s *Scene) Bound() bound.Bound

Bound returns a bounding box that contains every object in the scene.

func (*Scene) Camera

func (s *Scene) Camera() Camera

Camera returns the scene's current camera.

func (*Scene) DoDepth

func (s *Scene) DoDepth() bool

func (*Scene) GetObject

func (s *Scene) GetObject(id ObjectID) (obj Object3D, found bool)

GetObject retrieves the object with a given ID.

func (*Scene) Intersect

func (s *Scene) Intersect(r Ray, dist float64) Collision

Intersect returns the surface point that intersects with the given ray.

func (*Scene) Lights

func (s *Scene) Lights() []Light

Lights returns all of the lights added to the scene.

func (*Scene) SetAntialiasing

func (s *Scene) SetAntialiasing(numSamples, numPasses, incSamples int, threshold float64)

SetAntialiasing changes the parameters for antialiasing.

func (*Scene) SetBackground

func (s *Scene) SetBackground(bg Background)

SetBackground changes the scene's current background.

func (*Scene) SetCamera

func (s *Scene) SetCamera(cam Camera)

SetCamera changes the scene's current camera.

func (*Scene) Shadowed

func (s *Scene) Shadowed(r Ray, dist float64) bool

Shadowed returns whether a ray will cast a shadow.

func (*Scene) Update

func (s *Scene) Update() (err error)

Update causes the scene state to prepare for rendering. This is a potentially expensive operation. It will be called automatically before a Render.

type SurfaceIntegrator

type SurfaceIntegrator interface {
	Integrator
	SurfaceIntegrator()
}

A SurfaceIntegrator renders rays by casting onto solid objects.

type SurfacePoint

type SurfacePoint struct {
	Material  Material
	Light     Light
	Object    Object3D
	Primitive Primitive

	OriginX, OriginY int // Only used with "win" texture coordinate mode

	Normal, GeometricNormal, OrcoNormal vec64.Vector
	Position, OrcoPosition              vec64.Vector

	HasUV, HasOrco, Available bool
	PrimitiveNumber           int

	U, V               float64      // The texture coordinates
	NormalU, NormalV   vec64.Vector // Vectors building orthogonal shading space with normal
	WorldU, WorldV     vec64.Vector // U and V axes in world space
	ShadingU, ShadingV vec64.Vector // U and V axes in shading space
	SurfaceU, SurfaceV float64      // Raw surface parametric coordinates; required to evaluate Vmaps
}

SurfacePoint represents a single point on an object's surface.

type TransparentMaterial

type TransparentMaterial interface {
	Material
	// Transparency returns the color that the light is multiplied by when
	// passing through it.  If the color is black, then the material is opaque.
	Transparency(state *RenderState, sp SurfacePoint, wo vec64.Vector) color.Color
}

TransparentMaterial defines a material that can allow light to pass through it.

type Triangle

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

Triangle stores information for a single triangle.

func NewTriangle

func NewTriangle(a, b, c int, m *Mesh) (tri *Triangle)

NewTriangle creates a new triangle.

func (*Triangle) Bound

func (tri *Triangle) Bound() (bd bound.Bound)

func (*Triangle) CalculateNormal

func (tri *Triangle) CalculateNormal()

func (*Triangle) ClearNormals

func (tri *Triangle) ClearNormals()

func (*Triangle) ClearUVs

func (tri *Triangle) ClearUVs()

func (*Triangle) Clip

func (tri *Triangle) Clip(bound bound.Bound, axis vecutil.Axis, lower bool, oldData interface{}) (clipped bound.Bound, newData interface{})

func (*Triangle) GetNormal

func (tri *Triangle) GetNormal() vec64.Vector

func (*Triangle) Intersect

func (tri *Triangle) Intersect(r Ray) (coll Collision)

func (*Triangle) IntersectsBound

func (tri *Triangle) IntersectsBound(bd bound.Bound) bool

func (*Triangle) Material

func (tri *Triangle) Material() Material

func (*Triangle) SetMaterial

func (tri *Triangle) SetMaterial(mat Material)

func (*Triangle) SetNormals

func (tri *Triangle) SetNormals(a, b, c int)

func (*Triangle) SetUVs

func (tri *Triangle) SetUVs(a, b, c int)

func (*Triangle) String

func (tri *Triangle) String() string

func (*Triangle) Surface

func (tri *Triangle) Surface(coll Collision) (sp SurfacePoint)

func (*Triangle) SurfaceArea

func (tri *Triangle) SurfaceArea() float64

type UV

type UV [2]float64

UV holds a set of texture coordinates.

type Vmap

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

Vmap efficiently stores per-vertex data.

func NewVmap

func NewVmap(dimension, triCount int) (vm *Vmap)

NewVmap creates a new vertex map.

func (*Vmap) Dimension

func (vm *Vmap) Dimension() int

Dimension returns the number of values for each vertex.

func (*Vmap) GetValue

func (vm *Vmap) GetValue(triangle int) (vals []float64, ok bool)

GetValue returns all of the values for a triangle in the map.

func (*Vmap) Len

func (vm *Vmap) Len() int

Len returns the number of vertices stored in the map.

func (*Vmap) PushTriValue

func (vm *Vmap) PushTriValue(vals []float64) (ok bool)

PushTriValue pushes three sets of vertex values. It increases the size of the map.

func (*Vmap) SetValue

func (vm *Vmap) SetValue(triangle, vertex int, vals []float64) (ok bool)

SetValue changes the values for a vertex.

type VolumeHandler

type VolumeHandler interface {
	Transmittance(state *RenderState, r Ray) (color.Color, bool)
	Scatter(state *RenderState, r Ray) (Ray, PhotonSample, bool)
}

VolumeHandler defines a type that handles light scattering.

type VolumeIntegrator

type VolumeIntegrator interface {
	Integrator
	VolumeIntegrator()
	Transmittance(scene *Scene, state *RenderState, r Ray) color.AlphaColor
}

A VolumeIntegrator renders rays by casting onto volumetric regions.

type VolumeRegion

type VolumeRegion interface {
	// SigmaA returns the amount of light absorption in the volume.
	SigmaA(p, v vec64.Vector) color.Color

	// SigmaS returns the amount of light scattering in the volume.
	SigmaS(p, v vec64.Vector) color.Color

	// Emission returns the amout of light the volume emits.
	Emission(p, v vec64.Vector) color.Color

	SigmaT(p, v vec64.Vector) color.Color

	// Attenuation returns how much the volumetric effect dissipates over distance.
	Attenuation(p vec64.Vector, l Light) float64

	P(l, s vec64.Vector) float64

	Tau(r Ray, step, offset float64) color.Color

	// Intersect returns whether a ray intersects the volume.
	Intersect(r Ray) (t0, t1 float64, ok bool)

	// Bound returns the bounding box of the volume.
	Bound() bound.Bound
}

VolumeRegion defines a volumetric effect.

type VolumetricMaterial

type VolumetricMaterial interface {
	Material
	// VolumeTransmittance allows attenuation due to intra-object volumetric effects.
	VolumeTransmittance(state *RenderState, sp SurfacePoint, r Ray) (color.Color, bool)

	// VolumeHandler returns the volumetric handler for the space on a given side.
	VolumeHandler(inside bool) VolumeHandler
}

VolumetricMaterial defines a material that is aware of volumetric effects.

Directories

Path Synopsis
Package bound provides a bounding box type, along with various manipulation operations.
Package bound provides a bounding box type, along with various manipulation operations.
Package cameras provides standard perspective and orthographic cameras.
Package cameras provides standard perspective and orthographic cameras.
Package color provides abstracted color.
Package color provides abstracted color.
Package intersect contains algorithms for handling ray-collision detection.
Package intersect contains algorithms for handling ray-collision detection.
Package job specifies a consistent description of a render job.
Package job specifies a consistent description of a render job.
Package kdtree provides a generic kd-tree implementation.
Package kdtree provides a generic kd-tree implementation.
Package log provides an interface for multi-level logging.
Package log provides an interface for multi-level logging.
Package montecarlo provides numerical algorithms helpful for performing Monte Carlo approximations.
Package montecarlo provides numerical algorithms helpful for performing Monte Carlo approximations.
primitives
sphere
Package sphere provides a spherical primitive.
Package sphere provides a spherical primitive.
Package sampleutil provides useful sampling functions.
Package sampleutil provides useful sampling functions.
Package shader is a node-based shader system.
Package shader is a node-based shader system.
shaders
texmap
Package texmap provides a shader node that performs texture mapping with various options.
Package texmap provides a shader node that performs texture mapping with various options.
yaml
data
The data package has various ways to work with generic data.
The data package has various ways to work with generic data.
parser
The parser package takes a sequence of tokens and transforms it into a representation graph (and optionally into native data structures).
The parser package takes a sequence of tokens and transforms it into a representation graph (and optionally into native data structures).
scanner
The scanner package is responsible for parsing a YAML document and transforming it into a sequence of events.
The scanner package is responsible for parsing a YAML document and transforming it into a sequence of events.
token
The token package contains constants for YAML token types.
The token package contains constants for YAML token types.

Jump to

Keyboard shortcuts

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