material

package
v0.0.0-...-c2c5ea0 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2017 License: BSD-2-Clause Imports: 4 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
}

func NewBasic

func NewBasic() *Basic

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
)

type IMaterial

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

Interface for all materials

type Material

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

Base Material

func NewMaterial

func NewMaterial() *Material

NewMaterial 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

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)

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)

Sets the visible side(s) (SideFront | SideBack | SideDouble)

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)

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) UseLights

func (mat *Material) UseLights() UseLights

UseLights returns the current use lights bitmask

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 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) RenderSetup

func (pm *Point) RenderSetup(gs *gls.GLS)

RenderSetup is called by the engine before drawing the object which uses this 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

Material visible side(s)

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

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

Use lights 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