texmap

package
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: 10 Imported by: 0

Documentation

Overview

Package texmap provides a shader node that performs texture mapping with various options.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Construct

func Construct(m yamldata.Map) (data interface{}, err error)

Types

type Coordinates

type Coordinates int

Coordinates specifies which coordinate system to use during texture mapping.

const (
	UV        Coordinates = iota // UV-mapping
	Global                       // Global coordinates
	Orco                         // Original coordinates
	Transform                    // Transformation matrix
	Window                       // Viewport-relative
)

type DiscreteTexture

type DiscreteTexture interface {
	Texture
	Resolution() (x, y, z int)
}

A DiscreteTexture is a texture which has quantized values (a raster image).

type Projector

type Projector interface {
	Project(p, n vec64.Vector) vec64.Vector
}

A Projector computes the projection of 3D space into a 2D texture coordinate.

var (
	FlatMap   Projector = ProjectorFunc(flatMap)
	TubeMap   Projector = ProjectorFunc(tubeMap)
	SphereMap Projector = ProjectorFunc(sphereMap)
	CubeMap   Projector = ProjectorFunc(cubeMap)
)

Built-in projection schemes

type ProjectorFunc

type ProjectorFunc func(p, n vec64.Vector) vec64.Vector

A ProjectorFunc is a simple function-based projector.

func (ProjectorFunc) Project

func (f ProjectorFunc) Project(p, n vec64.Vector) vec64.Vector

type Texture

type Texture interface {
	ColorAt(pt vec64.Vector) color.AlphaColor
	ScalarAt(pt vec64.Vector) float64
	Is3D() bool
	IsNormalMap() bool
}

A Texture is a 2D/3D function for surface values. This is usually based on a raster image, but could be procedurally generated.

type TextureMapper

type TextureMapper struct {
	Texture          Texture      // The 2D/3D texture to apply
	Coordinates      Coordinates  // The coordinate system to use
	Projector        Projector    // The 3D projection type to use
	MapX, MapY, MapZ vecutil.Axis // Axis re-mapping (use -1 to indicate zero)
	Transform        mat64.Matrix // Transformation matrix (if using Transform coordinates)
	Scale, Offset    vec64.Vector // Constant scale and offset for coordinates
	Scalar           bool         // Should the result be a scalar?
	BumpStrength     float64      // Bump mapping weight
	// contains filtered or unexported fields
}

A TextureMapper is a shader that applies a texture to geometry.

func New

func New(tex Texture, coord Coordinates, scalar bool) (tmap *TextureMapper)

New creates a new texture mapper with the given parameters.

func (*TextureMapper) Dependencies

func (tmap *TextureMapper) Dependencies() []shader.Node

func (*TextureMapper) Eval

func (tmap *TextureMapper) Eval(inputs []shader.Result, params shader.Params) (result shader.Result)

func (*TextureMapper) EvalDerivative

func (tmap *TextureMapper) EvalDerivative(inputs []shader.Result, params shader.Params) (result shader.Result)

func (*TextureMapper) Init

func (tmap *TextureMapper) Init(tex Texture, coord Coordinates, scalar bool)

Init initializes the mapper with default values. You must call this method before using the mapper (but it is called automatically by New).

func (*TextureMapper) ViewDependent

func (tmap *TextureMapper) ViewDependent() bool

Jump to

Keyboard shortcuts

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