texture

package
v0.0.0-...-405cb25 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package texture provides implementations of the texture interface. This interface is that of a 3D ("solid") texture, i.e., a Color defined at every point in 3D space:

type Texture interface {
	At(p Vec) Color
}

The position p where the Texture is evaluated is usually local the corresponding Object (HitRecord.Local).

Solid textures can either be directly generated (often procedurally), or obtained by mapping a 2D texture onto 3D space ("UV mapping").

Textures are used wherever a space-dependent value (Color or otherwise) is needed.

  • Materials (package material) use textures for reflectivity values.
  • Some Objects (package object) use textures to modify shapes. E.g.: bump mapping, offset mapping. In that case the texture's Color is interpeted as number rather than a color.
  • Some Material and texture implementations use textures as masks for blending other materials or textures. In that case colors are used as weights.

Texture2D and UV Mapping

Images and interpolation

An image can be turned into a 2D texture by interpolation, i.e., indexing the image via floating point coordinates (u, v).

Color and float values

Some textures are inherently scalar-valued, rather than Color-valued. (E.g.: grayscale images or bump maps.) We do not expose a separate interface for those. Instead, we simply return a Color and later use only one component. This avoids having to implement texture manipulations for both scalar- and Color-valued textures.

TODO: provide Adapter.

TODO

Decide the package for this interface. material, builder, both?, tracer?

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConstScalar3D

type ConstScalar3D float64

func (ConstScalar3D) At

func (c ConstScalar3D) At(_ Vec) float64

type Func

type Func func(p Vec) Color

func (Func) At

func (f Func) At(p Vec) Color

type Func2D

type Func2D func(u, v float64) Color

Func2D adapts a function to a 2D texture.

func (Func2D) At

func (f Func2D) At(p Vec) Color

func (Func2D) AtUV

func (f Func2D) AtUV(u, v float64) Color

AtUV implements Texture2D by calling the function.

type Texture

type Texture interface {
	At(p geom.Vec) colorf.Color
}

Texture maps each point in 3D space to a color.

func Checkers

func Checkers(pitchU, pitchV float64, a, b Texture) Texture

Checkers returns a checkboard pattern alternating between textures a and b. pitchU, pitchV is the number of repetition per unit length. E.g.:

Checkers(1, 1, color.White, color.Black)

func Grid

func Grid(width, pitchU, pitchV float64, a, b Texture) Texture

func HeightMap

func HeightMap(file string) Texture

func MapFisheye

func MapFisheye(t Texture) Texture

func MustLoad

func MustLoad(file string) Texture

func Nearest

func Nearest(img imagef.Image) Texture

func Pan

func Pan(t Texture, deltaU, deltaV float64) Texture

TODO: reuse package geom transforms!

func ScaleUV

func ScaleUV(t Texture, scaleU, scaleV float64) Texture

type Texturef

type Texturef interface {
	At(p geom.Vec) float64
}

Texturef maps each point in 3D space to a number. TODO: remove?

func ScalarFunc3D

func ScalarFunc3D(f func(Vec) float64) Texturef

TODO: rename

Jump to

Keyboard shortcuts

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