material

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: GPL-3.0 Imports: 11 Imported by: 1

Documentation

Overview

Package material provides material and texture related types and functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HitRecord

type HitRecord struct {
	HitPoint  geo.Vec3
	Normal    geo.Vec3
	Material  Material
	RayLength float64
	U         float64
	V         float64
	FrontFace bool
}

HitRecord is a collection of all interesting properties from when a ray hits a hittable object

type Isotropic

type Isotropic struct {
	NonLightEmittingMaterial
	Albedo Texture
}

Isotropic is a fog type material Should not be used directly, but is used internally by ConstantMedium hittable

func (Isotropic) Scatter

func (m Isotropic) Scatter(rayIn geo.Ray, rec *HitRecord) (bool, ScatterRecord)

Scatter returns a randomly scattered ray in any direction

func (Isotropic) ScatteringPdf added in v0.0.7

func (m Isotropic) ScatteringPdf(rec *HitRecord, scattered geo.Ray) float64

ScatteringPdf returns the pdf value for a given rays for the isotropic material

type LightEmittingMaterial added in v0.0.7

type LightEmittingMaterial interface {
	Emitted(rec *HitRecord) geo.Vec3
}

LightEmittingMaterial is a material that can emit light

type Material

type Material interface {
	PdfGeneratingMaterial
	LightEmittingMaterial
	IsLight() bool
	Scatter(rayIn geo.Ray, rec *HitRecord) (bool, ScatterRecord)
}

Material is the interface for types that describe how a ray behaves when hitting an object.

func NewDielectric added in v0.3.5

func NewDielectric(tex Texture, indexOfRefraction float64) Material

NewDielectric creates a new dielectric material

func NewLambertian added in v0.3.5

func NewLambertian(tex Texture) Material

NewLambertian creates a lambertian material

func NewLight added in v0.3.5

func NewLight(r, g, b float64) Material

NewLight creates a new diffuse light material

func NewMetal added in v0.3.5

func NewMetal(tex Texture, fuzz float64) Material

NewMetal creates a metal material

type NonLightEmittingMaterial added in v0.0.7

type NonLightEmittingMaterial struct{}

NonLightEmittingMaterial is to be used by materials that do not emit light

func (NonLightEmittingMaterial) Emitted added in v0.0.7

func (m NonLightEmittingMaterial) Emitted(rec *HitRecord) geo.Vec3

Emitted a non emitting material emits zero light

func (NonLightEmittingMaterial) IsLight added in v0.3.5

func (m NonLightEmittingMaterial) IsLight() bool

IsLight a non emitting material is not a light

type NonPdfGeneratingMaterial added in v0.0.7

type NonPdfGeneratingMaterial struct{}

NonPdfGeneratingMaterial is to be used by materials that do not use pdfs

func (NonPdfGeneratingMaterial) ScatteringPdf added in v0.0.7

func (m NonPdfGeneratingMaterial) ScatteringPdf(rec *HitRecord, scattered geo.Ray) float64

ScatteringPdf as NonPdfGeneratingMaterial is used for materials that do not generate a pdf Just return 0

type PdfGeneratingMaterial added in v0.0.7

type PdfGeneratingMaterial interface {
	ScatteringPdf(rec *HitRecord, scattered geo.Ray) float64
}

PdfGeneratingMaterial is a material that can use pdfs for scattering of rays

type ScatterRecord added in v0.0.7

type ScatterRecord struct {
	Attenuation geo.Vec3
	Pdf         pdf.Pdf
	SkipPdf     bool
	SkipPdfRay  geo.Ray
}

ScatterRecord is a collection of attributes from the scattering of a ray with a material

type SolidColor

type SolidColor struct {
	ColorValue geo.Vec3
}

SolidColor is a texture with just the same color everywhere

func (SolidColor) Color

func (sc SolidColor) Color(rec *HitRecord) geo.Vec3

Color returns the solid color

type Texture

type Texture interface {
	Color(rec *HitRecord) geo.Vec3
}

Texture describes the color of a material. The color can vary by the uv coordinates of the hittable

func LoadImageTexture added in v0.3.5

func LoadImageTexture(path string) (Texture, error)

LoadImageTexture creates a texture that uses image data for color by loading the image from the path

func NewImageTexture added in v0.3.4

func NewImageTexture(image im.Image, mirror bool) Texture

NewImageTexture creates a texture that uses image data for color

func NewSolidColor added in v0.3.5

func NewSolidColor(r, g, b float64) Texture

Jump to

Keyboard shortcuts

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