material

package
v0.0.0-...-d35cbbc Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2024 License: CC0-1.0 Imports: 9 Imported by: 0

Documentation

Overview

Package material implements the different materials and their properties.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Dielectric

type Dielectric struct {
	// contains filtered or unexported fields
}

Dielectric represents a dielectric material.

func NewDielectric

func NewDielectric(reIdx float64) *Dielectric

NewDielectric returns an instance of a dielectric material.

func (*Dielectric) Albedo

func (d *Dielectric) Albedo(u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl

func (*Dielectric) Emitted

func (d *Dielectric) Emitted(_ ray.Ray, _ *hitrecord.HitRecord, _ float64, _ float64, _ *vec3.Vec3Impl) *vec3.Vec3Impl

func (*Dielectric) IsEmitter

func (d *Dielectric) IsEmitter() bool

IsEmitter() is true for dielectric materials as they reflect light and can be considered emitters.

func (*Dielectric) NormalMap

func (np *Dielectric) NormalMap() texture.Texture

func (*Dielectric) Scatter

Scatter computes how the ray bounces off the surface of a dielectric material.

func (*Dielectric) ScatteringPDF

func (d *Dielectric) ScatteringPDF(r ray.Ray, hr *hitrecord.HitRecord, scattered ray.Ray) float64

ScatteringPDF implements the probability distribution function for dielectric materials.

type DiffuseLight

type DiffuseLight struct {
	// contains filtered or unexported fields
}

DiffuseLight represents a diffuse light material.

func NewDiffuseLight

func NewDiffuseLight(emit texture.Texture) *DiffuseLight

NewDiffuseLight returns an instance of a diffuse light.

func (*DiffuseLight) Albedo

func (dl *DiffuseLight) Albedo(u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl

func (*DiffuseLight) Emitted

func (dl *DiffuseLight) Emitted(rIn ray.Ray, rec *hitrecord.HitRecord, u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl

Emitted returns the texture value at that point.

func (*DiffuseLight) IsEmitter

func (dl *DiffuseLight) IsEmitter() bool

func (*DiffuseLight) NormalMap

func (np *DiffuseLight) NormalMap() texture.Texture

func (*DiffuseLight) Scatter

Scatter returns false for diffuse light materials.

func (*DiffuseLight) ScatteringPDF

func (dl *DiffuseLight) ScatteringPDF(r ray.Ray, hr *hitrecord.HitRecord, scattered ray.Ray) float64

ScatteringPDF implements the probability distribution function for diffuse lights.

type Isotropic

type Isotropic struct {
	// contains filtered or unexported fields
}

Isotropic represents an isotropic material.

func NewIsotropic

func NewIsotropic(albedo texture.Texture) *Isotropic

NewIsotropic returns a new instances of the isotropic material.

func (*Isotropic) Albedo

func (i *Isotropic) Albedo(u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl

func (*Isotropic) Emitted

func (ne *Isotropic) Emitted(_ ray.Ray, _ *hitrecord.HitRecord, _ float64, _ float64, _ *vec3.Vec3Impl) *vec3.Vec3Impl

Emitted returns black for non-emitter materials.

func (*Isotropic) IsEmitter

func (ne *Isotropic) IsEmitter() bool

func (*Isotropic) NormalMap

func (np *Isotropic) NormalMap() texture.Texture

func (*Isotropic) Scatter

Scatter computes how the ray bounces off the surface of a diffuse material.

func (*Isotropic) ScatteringPDF

func (i *Isotropic) ScatteringPDF(r ray.Ray, hr *hitrecord.HitRecord, scattered ray.Ray) float64

ScatteringPDF implements the probability distribution function for isotropic materials.

type Lambertian

type Lambertian struct {
	// contains filtered or unexported fields
}

Lambertian represents a diffuse material.

func NewLambertian

func NewLambertian(albedo texture.Texture) *Lambertian

NewLambertian returns an instance of the Lambert material.

func (*Lambertian) Albedo

func (l *Lambertian) Albedo(u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl

func (*Lambertian) Emitted

func (ne *Lambertian) Emitted(_ ray.Ray, _ *hitrecord.HitRecord, _ float64, _ float64, _ *vec3.Vec3Impl) *vec3.Vec3Impl

Emitted returns black for non-emitter materials.

func (*Lambertian) IsEmitter

func (ne *Lambertian) IsEmitter() bool

func (*Lambertian) NormalMap

func (np *Lambertian) NormalMap() texture.Texture

func (*Lambertian) Scatter

Scatter computes how the ray bounces off the surface of a diffuse material.

func (*Lambertian) ScatteringPDF

func (l *Lambertian) ScatteringPDF(r ray.Ray, hr *hitrecord.HitRecord, scattered ray.Ray) float64

ScatteringPDF implements the probability distribution function for diffuse materials.

type Material

type Material interface {
	Scatter(r ray.Ray, hr *hitrecord.HitRecord, random *fastrandom.LCG) (*ray.RayImpl, *scatterrecord.ScatterRecord, bool)
	NormalMap() texture.Texture
	Albedo(u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl
	ScatteringPDF(r ray.Ray, hr *hitrecord.HitRecord, scattered ray.Ray) float64
	IsEmitter() bool
	Emitted(rIn ray.Ray, rec *hitrecord.HitRecord, u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl
}

Material defines the methods to handle materials.

type Metal

type Metal struct {
	// contains filtered or unexported fields
}

Metal represents metallic materials.

func NewMetal

func NewMetal(albedo *vec3.Vec3Impl, fuzz float64) *Metal

NewMetal returns an instance of the metal material.

func (*Metal) Albedo

func (m *Metal) Albedo(u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl

func (*Metal) Emitted

func (ne *Metal) Emitted(_ ray.Ray, _ *hitrecord.HitRecord, _ float64, _ float64, _ *vec3.Vec3Impl) *vec3.Vec3Impl

Emitted returns black for non-emitter materials.

func (*Metal) IsEmitter

func (ne *Metal) IsEmitter() bool

func (*Metal) NormalMap

func (np *Metal) NormalMap() texture.Texture

func (*Metal) Scatter

Scatter computes how the ray bounces off the surface of a metallic object.

func (*Metal) ScatteringPDF

func (m *Metal) ScatteringPDF(r ray.Ray, hr *hitrecord.HitRecord, scattered ray.Ray) float64

ScatteringPDF implements the probability distribution function for metals.

type PBR

type PBR struct {
	// contains filtered or unexported fields
}

func NewPBR

func NewPBR(albedo, normalMap, roughness, metalness texture.Texture) *PBR

NewPBR returns a new PBR material with the supplied textures.

func (*PBR) Albedo

func (pbr *PBR) Albedo(u float64, v float64, p *vec3.Vec3Impl) *vec3.Vec3Impl

func (*PBR) Emitted

func (ne *PBR) Emitted(_ ray.Ray, _ *hitrecord.HitRecord, _ float64, _ float64, _ *vec3.Vec3Impl) *vec3.Vec3Impl

Emitted returns black for non-emitter materials.

func (*PBR) IsEmitter

func (ne *PBR) IsEmitter() bool

func (*PBR) NormalMap

func (pbr *PBR) NormalMap() texture.Texture

NormalMap() returns the normal map associated with this material.

func (*PBR) Scatter

func (pbr *PBR) Scatter(r ray.Ray, hr *hitrecord.HitRecord, random *fastrandom.LCG) (*ray.RayImpl, *scatterrecord.ScatterRecord, bool)

Scatter computes how the ray bounces off the surface of a PBR material.

func (*PBR) ScatteringPDF

func (pbr *PBR) ScatteringPDF(r ray.Ray, hr *hitrecord.HitRecord, scattered ray.Ray) float64

ScatteringPDF implements the probability distribution function for PBR materials.

Jump to

Keyboard shortcuts

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