material

package
v0.2.88 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2025 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package material contains virtual materials which specify the appearance of graphic objects.

Index

Constants

View Source
const (
	SideFront = Side(iota)
	SideBack
	SideDouble
)

The face side(s) to be rendered. The non-rendered side will be culled to improve performance.

View Source
const (
	BlendNone = Blending(iota)
	BlendNormal
	BlendAdditive
	BlendSubtractive
	BlendMultiply
	BlendCustom
)

The various blending types.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

type Basic struct {
	Material
}

Basic is a simple material that uses the 'basic' shader.

func NewBasic

func NewBasic() *Basic

NewBasic creates a new Basic material.

type Blending

type Blending int

Blending specifies the blending mode.

type IMaterial

type IMaterial interface {
	core.IRefCount
	GetMaterial() *Material
	RenderSetup(gs *gls.GLS)
	Dispose()
}

IMaterial is the interface for all materials.

type Material

type Material struct {
	core.RefCount

	ShaderDefines gls.MaterialDefines // shader defines
	// contains filtered or unexported fields
}

Material is the base material.

func NewMaterial

func NewMaterial() *Material

NewMaterial creates a new Material.

func (*Material) AddTexture

func (m *Material) AddTexture(tex *texture.Texture2D)

AddTexture adds the specified texture to the material

func (*Material) Dispose

func (m *Material) Dispose()

Dispose releases OpenGL resources associated with this material.

func (*Material) GetMaterial

func (m *Material) GetMaterial() *Material

GetMaterial satisfies the IMaterial interface.

func (*Material) HasTexture

func (m *Material) HasTexture(tex *texture.Texture2D) bool

HasTexture checks if the material contains the specified texture

func (*Material) InitMaterial added in v0.2.69

func (m *Material) InitMaterial() *Material

InitMaterial initializes the material.

func (*Material) RemoveTexture

func (m *Material) RemoveTexture(tex *texture.Texture2D)

RemoveTexture removes the specified texture from the material

func (*Material) RenderSetup

func (m *Material) RenderSetup(gs *gls.GLS)

RenderSetup is called by the renderer before drawing objects with this material.

func (*Material) SetBlending

func (m *Material) SetBlending(blending Blending)

func (*Material) SetDepthFunc

func (m *Material) SetDepthFunc(state uint32)

func (*Material) SetDepthMask

func (m *Material) SetDepthMask(state bool)

func (*Material) SetDepthTest

func (m *Material) SetDepthTest(state bool)

func (*Material) SetLineWidth

func (m *Material) SetLineWidth(width float32)

func (*Material) SetPolygonOffset

func (m *Material) SetPolygonOffset(factor, units float32)

func (*Material) SetShader

func (m *Material) SetShader(sname string)

SetShader sets the name of the shader program for this material

func (*Material) SetSide

func (m *Material) SetSide(side Side)

SetSide sets the visible side(s) (SideFront | SideBack | SideDouble)

func (*Material) SetTransparent

func (m *Material) SetTransparent(state bool)

SetTransparent sets whether this material is transparent.

func (*Material) SetUseLights

func (m *Material) SetUseLights(lights UseLights)

SetUseLights sets the material use lights bit mask specifying which light types will be used when rendering the material By default the material will use all lights

func (*Material) SetWireframe

func (m *Material) SetWireframe(state bool)

SetWireframe sets whether only the wireframe is rendered.

func (*Material) Shader

func (m *Material) Shader() string

Shader returns the current name of the shader program for this material

func (*Material) Side

func (m *Material) Side() Side

Side returns the current side visibility for this material

func (*Material) TextureCount

func (m *Material) TextureCount() int

TextureCount returns the current number of textures

func (*Material) Textures

func (m *Material) Textures() []*texture.Texture2D

Textures returns a slice with this material's textures

func (*Material) Transparent

func (m *Material) Transparent() bool

Transparent returns whether this material has been set as transparent.

func (*Material) UseLights

func (m *Material) UseLights() UseLights

UseLights returns the current use lights bitmask

func (*Material) Wireframe

func (m *Material) Wireframe() bool

Wireframe returns whether only the wireframe is rendered.

type Physical

type Physical struct {
	Material // Embedded material
	// contains filtered or unexported fields
}

Physical is a physically based rendered material which uses the metallic-roughness model.

func NewPhysical

func NewPhysical() *Physical

NewPhysical creates a new Physical material.

func (*Physical) InitPhysical added in v0.2.69

func (m *Physical) InitPhysical()

InitPhysical initializes the material.

func (*Physical) RenderSetup

func (m *Physical) RenderSetup(gl *gls.GLS)

RenderSetup transfers this material's uniforms and textures to the shader.

func (*Physical) SetBaseColorFactor

func (m *Physical) SetBaseColorFactor(c math32.Color4)

SetBaseColorFactor sets this material's base color. Its default value is {1,1,1,1}.

func (*Physical) SetBaseColorMap

func (m *Physical) SetBaseColorMap(tex *texture.Texture2D)

SetBaseColorMap sets this material's optional texture base color.

func (*Physical) SetEmissiveFactor

func (m *Physical) SetEmissiveFactor(c math32.Color)

SetEmissiveFactor sets this material's emissive. Its default is {1, 1, 1}.

func (*Physical) SetEmissiveMap

func (m *Physical) SetEmissiveMap(tex *texture.Texture2D)

SetEmissiveMap sets this material's optional emissive texture.

func (*Physical) SetMetallicFactor

func (m *Physical) SetMetallicFactor(v float32)

SetMetallicFactor sets this material's metallic factor. Its default value is 1.

func (*Physical) SetMetallicRoughnessMap

func (m *Physical) SetMetallicRoughnessMap(tex *texture.Texture2D)

SetMetallicRoughnessMap sets this material's optional metallic-roughness texture.

func (*Physical) SetNormalMap

func (m *Physical) SetNormalMap(tex *texture.Texture2D)

SetNormalMap sets this material's optional normal texture.

func (*Physical) SetOcclusionMap

func (m *Physical) SetOcclusionMap(tex *texture.Texture2D)

SetOcclusionMap sets this material's optional occlusion texture.

func (*Physical) SetRoughnessFactor

func (m *Physical) SetRoughnessFactor(v float32)

SetRoughnessFactor sets this material's roughness factor. Its default value is 1.

type Point

type Point struct {
	Standard
}

Point material is normally used for single point sprites.

func NewPoint

func NewPoint(color math32.Color) *Point

NewPoint creates a new Point material.

func (*Point) InitPoint added in v0.2.69

func (m *Point) InitPoint(color math32.Color)

InitPoint initializes the material setting the specified color.

func (*Point) SetEmissiveColor

func (m *Point) SetEmissiveColor(color math32.Color)

SetEmissiveColor sets the material's emissive color. The default is {0,0,0}.

func (*Point) SetRotationZ

func (m *Point) SetRotationZ(rot float32)

SetRotationZ sets the point rotation around the Z axis.

func (*Point) SetSize

func (m *Point) SetSize(size float32)

SetSize sets the point size.

type Side

type Side int

Side represents the material's visible side(s).

type Standard

type Standard struct {
	Material // Embedded material
	// contains filtered or unexported fields
}

Standard is a material that supports the classic lighting model with ambient, diffuse, specular and emissive lights. The lighting calculation is implemented in the vertex shader.

func NewBlinnPhong

func NewBlinnPhong(color math32.Color) *Standard

NewBlinnPhong creates and returns a pointer to a new Standard material using Blinn-Phong model. It is very close to Standard (Phong) model so we need only pass a parameter.

func NewStandard

func NewStandard(color math32.Color) *Standard

NewStandard creates and returns a pointer to a new standard material.

func (*Standard) AmbientColor

func (m *Standard) AmbientColor() math32.Color

AmbientColor returns the material ambient color reflectivity.

func (*Standard) EmissiveColor

func (m *Standard) EmissiveColor() math32.Color

EmissiveColor returns the material current emissive color.

func (*Standard) InitStandard added in v0.2.69

func (m *Standard) InitStandard(color math32.Color)

InitStandard initializes the material setting the specified color.

func (*Standard) RenderSetup

func (m *Standard) RenderSetup(gs *gls.GLS)

RenderSetup is called before drawing the object which uses this material.

func (*Standard) SetAmbientColor

func (m *Standard) SetAmbientColor(color math32.Color)

SetAmbientColor sets the material ambient color reflectivity. The default is the same as the diffuse color.

func (*Standard) SetColor

func (m *Standard) SetColor(color math32.Color)

SetColor sets the material diffuse color and also the material ambient color reflectivity.

func (*Standard) SetEmissiveColor

func (m *Standard) SetEmissiveColor(color math32.Color)

SetEmissiveColor sets the material emissive color. The default is {0,0,0}.

func (*Standard) SetOpacity

func (m *Standard) SetOpacity(opacity float32)

SetOpacity sets the material opacity (alpha). The default is 1.0.

func (*Standard) SetShininess

func (m *Standard) SetShininess(shininess float32)

SetShininess sets the specular highlight factor. The default is 30.

func (*Standard) SetSpecularColor

func (m *Standard) SetSpecularColor(color math32.Color)

SetSpecularColor sets the material specular color reflectivity. The default is {0.5, 0.5, 0.5}.

type UseLights

type UseLights int

UseLights is a bitmask that specifies which types of lights affect the material.

const (
	UseLightNone        UseLights = 0x00
	UseLightAmbient     UseLights = 0x01
	UseLightDirectional UseLights = 0x02
	UseLightPoint       UseLights = 0x04
	UseLightSpot        UseLights = 0x08
	UseLightAll         UseLights = 0xFF
)

The possible UseLights values.

Jump to

Keyboard shortcuts

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