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.