engine: github.com/g3n/engine/material Index | Files

package material

import "github.com/g3n/engine/material"

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

Index

Package Files

basic.go logger.go material.go phong.go physical.go point.go standard.go

type Basic Uses

type Basic struct {
    Material // Embedded material
}

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

func NewBasic Uses

func NewBasic() *Basic

NewBasic returns a pointer to a new Basic material

type Blending Uses

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 Uses

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

IMaterial is the interface for all materials.

type Material Uses

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

Material is the base material.

func NewMaterial Uses

func NewMaterial() *Material

NewMaterial creates and returns a pointer to a new Material.

func (*Material) AddTexture Uses

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

AddTexture adds the specified Texture2d to the material

func (*Material) Dispose Uses

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 Uses

func (mat *Material) GetMaterial() *Material

GetMaterial satisfies the IMaterial interface.

func (*Material) HasTexture Uses

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

HasTexture checks if the material contains the specified texture

func (*Material) Incref Uses

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 Uses

func (mat *Material) Init() *Material

Init initializes the material.

func (*Material) RemoveTexture Uses

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

RemoveTexture removes the specified Texture2d from the material

func (*Material) RenderSetup Uses

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

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

func (*Material) SetBlending Uses

func (mat *Material) SetBlending(blending Blending)

func (*Material) SetDepthMask Uses

func (mat *Material) SetDepthMask(state bool)

func (*Material) SetDepthTest Uses

func (mat *Material) SetDepthTest(state bool)

func (*Material) SetLineWidth Uses

func (mat *Material) SetLineWidth(width float32)

func (*Material) SetPolygonOffset Uses

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

func (*Material) SetShader Uses

func (mat *Material) SetShader(sname string)

SetShader sets the name of the shader program for this material

func (*Material) SetShaderUnique Uses

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 Uses

func (mat *Material) SetSide(side Side)

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

func (*Material) SetTransparent Uses

func (mat *Material) SetTransparent(state bool)

SetTransparent sets whether this material is transparent.

func (*Material) SetUseLights Uses

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 Uses

func (mat *Material) SetWireframe(state bool)

SetWireframe sets whether only the wireframe is rendered.

func (*Material) Shader Uses

func (mat *Material) Shader() string

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

func (*Material) ShaderUnique Uses

func (mat *Material) ShaderUnique() bool

ShaderUnique returns this material shader is unique.

func (*Material) Side Uses

func (mat *Material) Side() Side

Side returns the current side visibility for this material

func (*Material) TextureCount Uses

func (mat *Material) TextureCount() int

TextureCount returns the current number of textures

func (*Material) Transparent Uses

func (mat *Material) Transparent() bool

Transparent returns whether this material is transparent.

func (*Material) UseLights Uses

func (mat *Material) UseLights() UseLights

UseLights returns the current use lights bitmask

func (*Material) Wireframe Uses

func (mat *Material) Wireframe() bool

Wireframe returns whether only the wireframe is rendered.

type Phong Uses

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 Uses

func NewPhong(color *math32.Color) *Phong

NewPhong creates and returns a pointer to a new phong material

type Physical Uses

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 Uses

func NewPhysical() *Physical

NewPhysical creates and returns a pointer to a new Physical material.

func (*Physical) RenderSetup Uses

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

RenderSetup transfer this material uniforms and textures to the shader

func (*Physical) SetBaseColorFactor Uses

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 Uses

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 Uses

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 Uses

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

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

func (*Physical) SetMetallicFactor Uses

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 Uses

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 Uses

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 Uses

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

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

func (*Physical) SetRoughnessFactor Uses

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 Uses

type Point struct {
    Standard // Embedded standard material
}

Point material is normally used for single point sprites

func NewPoint Uses

func NewPoint(color *math32.Color) *Point

NewPoint creates and returns a pointer to a new point material

func (*Point) SetEmissiveColor Uses

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

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

func (*Point) SetRotationZ Uses

func (pm *Point) SetRotationZ(rot float32)

SetRotationZ sets the point rotation around the Z axis.

func (*Point) SetSize Uses

func (pm *Point) SetSize(size float32)

SetSize sets the point size

type Side Uses

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 Uses

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 Uses

func NewStandard(color *math32.Color) *Standard

NewStandard creates and returns a pointer to a new standard material

func (*Standard) AmbientColor Uses

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

AmbientColor returns the material ambient color reflectivity.

func (*Standard) EmissiveColor Uses

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

EmissiveColor returns the material current emissive color

func (*Standard) Init Uses

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 Uses

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

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

func (*Standard) SetAmbientColor Uses

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 Uses

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

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

func (*Standard) SetEmissiveColor Uses

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

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

func (*Standard) SetOpacity Uses

func (ms *Standard) SetOpacity(opacity float32)

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

func (*Standard) SetShininess Uses

func (ms *Standard) SetShininess(shininess float32)

SetShininess sets the specular highlight factor. Default is 30.

func (*Standard) SetSpecularColor Uses

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 Uses

type UseLights int

UseLights flags

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

Package material imports 5 packages (graph) and is imported by 22 packages. Updated 2018-07-21. Refresh now. Tools for package owners.