material

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2020 License: BSD-2-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package material contains several types of materials which can be used to set the appearance of graphic object

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Basic

type Basic struct {
	Material // Embedded material
}

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

func NewBasic

func NewBasic() *Basic

NewBasic returns a pointer to a new Basic material

type Blending

type Blending int

Blending

const (
	BlendingNone        Blending = 0
	BlendingNormal      Blending = 1
	BlendingAdditive    Blending = 2
	BlendingSubtractive Blending = 3
	BlendingMultiply    Blending = 4
	BlendingCustom      Blending = 5
)

The various blending types

type IMaterial

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

IMaterial is the interface for all materials.

type Material

type Material struct {
	ShaderDefines gls.ShaderDefines // shader defines
	// contains filtered or unexported fields
}

Material is the base material.

func NewMaterial

func NewMaterial() *Material

NewMaterial creates and returns a pointer to a new Material.

func (*Material) AddTexture

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

AddTexture adds the specified Texture2d to the material

func (*Material) Dispose

func (mat *Material) Dispose()

Dispose decrements this material reference count and if necessary releases OpenGL resources, C memory and textures associated with this material.

func (*Material) GetMaterial

func (mat *Material) GetMaterial() *Material

GetMaterial satisfies the IMaterial interface.

func (*Material) HasTexture

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

HasTexture checks if the material contains the specified texture

func (*Material) Incref

func (mat *Material) Incref() *Material

Incref increments the reference count for this material and returns a pointer to the material. It should be used when this material is shared by another Graphic object.

func (*Material) Init

func (mat *Material) Init() *Material

Init initializes the material.

func (*Material) RemoveTexture

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

RemoveTexture removes the specified Texture2d from the material

func (*Material) RenderSetup

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

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

func (*Material) SetBlending

func (mat *Material) SetBlending(blending Blending)

func (*Material) SetDepthMask

func (mat *Material) SetDepthMask(state bool)

func (*Material) SetDepthTest

func (mat *Material) SetDepthTest(state bool)

func (*Material) SetLineWidth

func (mat *Material) SetLineWidth(width float32)

func (*Material) SetPolygonOffset

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

func (*Material) SetShader

func (mat *Material) SetShader(sname string)

SetShader sets the name of the shader program for this material

func (*Material) SetShaderUnique

func (mat *Material) SetShaderUnique(unique bool)

SetShaderUnique sets indication that this material shader is unique and does not depend on the number of lights in the scene and/or the number of textures in the material.

func (*Material) SetSide

func (mat *Material) SetSide(side Side)

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

func (*Material) SetTransparent

func (mat *Material) SetTransparent(state bool)

SetTransparent sets whether this material is transparent.

func (*Material) SetUseLights

func (mat *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 (mat *Material) SetWireframe(state bool)

SetWireframe sets whether only the wireframe is rendered.

func (*Material) Shader

func (mat *Material) Shader() string

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

func (*Material) ShaderUnique

func (mat *Material) ShaderUnique() bool

ShaderUnique returns this material shader is unique.

func (*Material) Side

func (mat *Material) Side() Side

Side returns the current side visibility for this material

func (*Material) TextureCount

func (mat *Material) TextureCount() int

TextureCount returns the current number of textures

func (*Material) Transparent

func (mat *Material) Transparent() bool

Transparent returns whether this material is transparent.

func (*Material) UseLights

func (mat *Material) UseLights() UseLights

UseLights returns the current use lights bitmask

func (*Material) Wireframe

func (mat *Material) Wireframe() bool

Wireframe returns whether only the wireframe is rendered.

type Phong

type Phong struct {
	Standard // Embedded standard material
}

Phong material is identical to the Standard material but the calculation of the lighting model is done in the fragment shader.

func NewPhong

func NewPhong(color *math32.Color) *Phong

NewPhong creates and returns a pointer to a new phong material

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 and returns a pointer to a new Physical material.

func (*Physical) RenderSetup

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

RenderSetup transfer this material uniforms and textures to the shader

func (*Physical) SetBaseColorFactor

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

SetBaseColorFactor sets this material base color. Its default value is {1,1,1,1}. Returns pointer to this updated material.

func (*Physical) SetBaseColorMap

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

SetBaseColorMap sets this material optional texture base color. Returns pointer to this updated material.

func (*Physical) SetEmissiveFactor

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

SetEmissiveFactor sets the emissive color of the material. Its default is {1, 1, 1}. Returns pointer to this updated material.

func (*Physical) SetEmissiveMap

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

SetEmissiveMap sets this material optional emissive texture. Returns pointer to this updated material.

func (*Physical) SetMetallicFactor

func (m *Physical) SetMetallicFactor(v float32) *Physical

SetMetallicFactor sets this material metallic factor. Its default value is 1. Returns pointer to this updated material.

func (*Physical) SetMetallicRoughnessMap

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

SetMetallicRoughnessMap sets this material optional metallic-roughness texture. Returns pointer to this updated material.

func (*Physical) SetNormalMap

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

SetNormalMap sets this material optional normal texture. Returns pointer to this updated material. TODO add SetNormalMap (and SetSpecularMap) to StandardMaterial.

func (*Physical) SetOcclusionMap

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

SetOcclusionMap sets this material optional occlusion texture. Returns pointer to this updated material.

func (*Physical) SetRoughnessFactor

func (m *Physical) SetRoughnessFactor(v float32) *Physical

SetRoughnessFactor sets this material roughness factor. Its default value is 1. Returns pointer to this updated material.

type Point

type Point struct {
	Standard // Embedded standard material
}

Point material is normally used for single point sprites

func NewPoint

func NewPoint(color *math32.Color) *Point

NewPoint creates and returns a pointer to a new point material

func (*Point) SetEmissiveColor

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

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

func (*Point) SetRotationZ

func (pm *Point) SetRotationZ(rot float32)

SetRotationZ sets the point rotation around the Z axis.

func (*Point) SetSize

func (pm *Point) SetSize(size float32)

SetSize sets the point size

type Side

type Side int

Side represents the material's visible side(s)

const (
	SideFront  Side = 0
	SideBack   Side = 1
	SideDouble Side = 2
)

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

type Standard

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

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

func NewStandard

func NewStandard(color *math32.Color) *Standard

NewStandard creates and returns a pointer to a new standard material

func (*Standard) AmbientColor

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

AmbientColor returns the material ambient color reflectivity.

func (*Standard) EmissiveColor

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

EmissiveColor returns the material current emissive color

func (*Standard) Init

func (ms *Standard) Init(shader string, color *math32.Color)

Init initializes the material setting the specified shader and color It is used mainly when the material is embedded in another type

func (*Standard) RenderSetup

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

RenderSetup is called by the engine before drawing the object which uses this material

func (*Standard) SetAmbientColor

func (ms *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 (ms *Standard) SetColor(color *math32.Color)

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

func (*Standard) SetEmissiveColor

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

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

func (*Standard) SetOpacity

func (ms *Standard) SetOpacity(opacity float32)

SetOpacity sets the material opacity (alpha). Default is 1.0.

func (*Standard) SetShininess

func (ms *Standard) SetShininess(shininess float32)

SetShininess sets the specular highlight factor. Default is 30.

func (*Standard) SetSpecularColor

func (ms *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 flags

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

Jump to

Keyboard shortcuts

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