Documentation
¶
Overview ¶
Package test provides test helpers for BruteRay.
- comparing rendered images to golden testdata
- minimal implementations of a few shapes and materials
Rendered images and golden testdata are saved under directories testdata/got and testdata/, respectively.
The minimal implementations of Sphere and Flat material allow tests without complex dependencies between packages like objects, materials, textures.
Index ¶
- Constants
- Variables
- func Benchmark(b *testing.B, s *Scene, c Camera, tolerance float64)
- func Check(t testing.TB, err error)
- func Checkers(a, b Material) Material
- func Compare(t testing.TB, tolerance float64, img image.Image)
- func Diff(A, B image.Image) float64
- func DiffImg(t testing.TB, a, b string) float64
- func NPass(t *testing.T, s *Scene, c Camera, numPass int, tolerance float64)
- func NPassSize(t *testing.T, s *Scene, c Camera, numPass, width, height int, ...)
- func OnePass(t *testing.T, s *Scene, c Camera, tolerance float64)
- func PointLight(pos Vec) Light
- func QuadView(t *testing.T, s *Scene, c Camera, fov float64, tolerance float64)
- func QuadViewN(t *testing.T, s *Scene, c Camera, fov float64, nPass int, tolerance float64)
- func Save(t testing.TB, img image.Image, fname string)
- func Sheet(m Material, height float64) Object
- func Sphere(m Material, diam float64, origin geom.Vec) Object
- func TestName() string
- func Testdata() string
- func Transparent(trans, add Color) Material
- func WithShadows(c Color) Material
- type Convergence
- type Flat
- type Row
Constants ¶
const ( DefaultTolerance = 1e-5 DefaultWidth = 300 DefaultHeight = 200 )
Variables ¶
var ( Blue = WithShadows(colorf.Blue) Cyan = WithShadows(colorf.Cyan) Gray = WithShadows(colorf.Gray(0.5)) Green = WithShadows(colorf.Green) Magenta = WithShadows(colorf.Magenta) White = WithShadows(colorf.White) Yellow = WithShadows(colorf.Yellow) Checkers1 = Checkers(White, Magenta) Checkers2 = Checkers(White, Cyan) Checkers3 = Checkers(White, Green) Checkers4 = Checkers(WithShadows(colorf.Gray(0.4)), WithShadows(colorf.Gray(0.7))) )
var Normal Material = &normal{1, 1, 1}
Normal is a non-physical material that reveals the component of the normal vector that points towards the camera. The normal pointing perpendicular to the direction of view is rendered as black. Away from the viewing direction is rendered as red to draw attention to visible backfaces.
var Normal2 = normal2{}
Functions ¶
func Checkers ¶
func Checkers(a, b Material) Material
Checkers alternates between materials a and b in a checkerboard pattern with period 1.
func NPassSize ¶
NPassSize is like NPass, but allows to set the image size. Intended to run costly tests at lower resolution.
func OnePass ¶
OnePass renders a scene with default size and one monte-carlo pass, and compares the result to testdata.
func PointLight ¶
func PointLight(pos Vec) Light
func QuadView ¶
QuadView renders the scene from 4 points of view
- the camera
- the X, Y and Z direction, orthgraphically
and compares the result to testdata.
func Sphere ¶
Sphere returns a minimal implementation of a sphere. Intended for tests that should not depend on package objects/
func TestName ¶
func TestName() string
TestName returns a name based on the calling Test function. E.g.:
github.com/barnex/bruteray/object.TestSphere -> object.sphere
func Testdata ¶
func Testdata() string
Testdata walks up the filesystem starting from the working directory in search of an existing subdirectory called "testdata".
func Transparent ¶
func Transparent(trans, add Color) Material
func WithShadows ¶
func WithShadows(c Color) Material
WithShadows returns a non-physical material similar to Normal, but overlayed with shadows.
Types ¶
type Convergence ¶
type Convergence struct { *tracer.Sampler Golden imagef.Image Output []Row // contains filtered or unexported fields }
func (*Convergence) Error ¶
func (c *Convergence) Error() Row
func (*Convergence) MustWrite ¶
func (c *Convergence) MustWrite(fname string)
func (*Convergence) Sample ¶
func (c *Convergence) Sample(nPass int)