Documentation ¶
Overview ¶
Package material contains virtual materials which specify the appearance of graphic objects.
Index ¶
- Constants
- type Basic
- type Blending
- type IMaterial
- type Material
- func (mat *Material) AddTexture(tex *texture.Texture2D)
- func (mat *Material) Dispose()
- func (mat *Material) GetMaterial() *Material
- func (mat *Material) HasTexture(tex *texture.Texture2D) bool
- func (mat *Material) Incref() *Material
- func (mat *Material) Init() *Material
- func (mat *Material) RemoveTexture(tex *texture.Texture2D)
- func (mat *Material) RenderSetup(gs *gls.GLS)
- func (mat *Material) SetBlending(blending Blending)
- func (mat *Material) SetDepthFunc(state uint32)
- func (mat *Material) SetDepthMask(state bool)
- func (mat *Material) SetDepthTest(state bool)
- func (mat *Material) SetLineWidth(width float32)
- func (mat *Material) SetPolygonOffset(factor, units float32)
- func (mat *Material) SetShader(sname string)
- func (mat *Material) SetSide(side Side)
- func (mat *Material) SetTransparent(state bool)
- func (mat *Material) SetUseLights(lights UseLights)
- func (mat *Material) SetWireframe(state bool)
- func (mat *Material) Shader() string
- func (mat *Material) Side() Side
- func (mat *Material) TextureCount() int
- func (mat *Material) Textures() []*texture.Texture2D
- func (mat *Material) Transparent() bool
- func (mat *Material) UseLights() UseLights
- func (mat *Material) Wireframe() bool
- type Physical
- func (m *Physical) RenderSetup(gl *gls.GLS)
- func (m *Physical) SetBaseColorFactor(c *math32.Color4) *Physical
- func (m *Physical) SetBaseColorMap(tex *texture.Texture2D) *Physical
- func (m *Physical) SetEmissiveFactor(c *math32.Color) *Physical
- func (m *Physical) SetEmissiveMap(tex *texture.Texture2D) *Physical
- func (m *Physical) SetMetallicFactor(v float32) *Physical
- func (m *Physical) SetMetallicRoughnessMap(tex *texture.Texture2D) *Physical
- func (m *Physical) SetNormalMap(tex *texture.Texture2D) *Physical
- func (m *Physical) SetOcclusionMap(tex *texture.Texture2D) *Physical
- func (m *Physical) SetRoughnessFactor(v float32) *Physical
- type Point
- type Side
- type Standard
- func (ms *Standard) AmbientColor() math32.Color
- func (ms *Standard) EmissiveColor() math32.Color
- func (ms *Standard) Init(shader string, color *math32.Color)
- func (ms *Standard) RenderSetup(gs *gls.GLS)
- func (ms *Standard) SetAmbientColor(color *math32.Color)
- func (ms *Standard) SetColor(color *math32.Color)
- func (ms *Standard) SetEmissiveColor(color *math32.Color)
- func (ms *Standard) SetOpacity(opacity float32)
- func (ms *Standard) SetShininess(shininess float32)
- func (ms *Standard) SetSpecularColor(color *math32.Color)
- type UseLights
Constants ¶
const ( SideFront = Side(iota) SideBack SideDouble )
The face side(s) to be rendered. The non-rendered side will be culled to improve performance.
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 // Embedded material
}
Basic is a simple material that uses the 'basic' shader
type Material ¶
type Material struct { ShaderDefines gls.MaterialDefines // 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 ¶
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 ¶
GetMaterial satisfies the IMaterial interface.
func (*Material) HasTexture ¶
HasTexture checks if the material contains the specified texture
func (*Material) Incref ¶
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) RemoveTexture ¶
RemoveTexture removes the specified Texture2d from the material
func (*Material) RenderSetup ¶
RenderSetup is called by the renderer before drawing objects with this material.
func (*Material) SetBlending ¶
func (*Material) SetDepthFunc ¶
func (*Material) SetDepthMask ¶
func (*Material) SetDepthTest ¶
func (*Material) SetLineWidth ¶
func (*Material) SetPolygonOffset ¶
func (*Material) SetTransparent ¶
SetTransparent sets whether this material is transparent.
func (*Material) SetUseLights ¶
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 ¶
SetWireframe sets whether only the wireframe is rendered.
func (*Material) TextureCount ¶
TextureCount returns the current number of textures
func (*Material) Transparent ¶
Transparent returns whether this material has been set as transparent.
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 ¶
RenderSetup transfer this material uniforms and textures to the shader
func (*Physical) SetBaseColorFactor ¶
SetBaseColorFactor sets this material base color. Its default value is {1,1,1,1}. Returns pointer to this updated material.
func (*Physical) SetBaseColorMap ¶
SetBaseColorMap sets this material optional texture base color. Returns pointer to this updated material.
func (*Physical) SetEmissiveFactor ¶
SetEmissiveFactor sets the emissive color of the material. Its default is {1, 1, 1}. Returns pointer to this updated material.
func (*Physical) SetEmissiveMap ¶
SetEmissiveMap sets this material optional emissive texture. Returns pointer to this updated material.
func (*Physical) SetMetallicFactor ¶
SetMetallicFactor sets this material metallic factor. Its default value is 1. Returns pointer to this updated material.
func (*Physical) SetMetallicRoughnessMap ¶
SetMetallicRoughnessMap sets this material optional metallic-roughness texture. Returns pointer to this updated material.
func (*Physical) SetNormalMap ¶
SetNormalMap sets this material optional normal texture. Returns pointer to this updated material.
func (*Physical) SetOcclusionMap ¶
SetOcclusionMap sets this material optional occlusion texture. Returns pointer to this updated material.
func (*Physical) SetRoughnessFactor ¶
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 (*Point) SetEmissiveColor ¶
SetEmissiveColor sets the material emissive color The default is {0,0,0}
func (*Point) SetRotationZ ¶
SetRotationZ sets the point rotation around the Z axis.
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 NewBlinnPhong ¶
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 ¶
NewStandard creates and returns a pointer to a new standard material
func (*Standard) AmbientColor ¶
AmbientColor returns the material ambient color reflectivity.
func (*Standard) EmissiveColor ¶
EmissiveColor returns the material current emissive color
func (*Standard) Init ¶
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 ¶
RenderSetup is called by the engine before drawing the object which uses this material
func (*Standard) SetAmbientColor ¶
SetAmbientColor sets the material ambient color reflectivity. The default is the same as the diffuse color
func (*Standard) SetColor ¶
SetColor sets the material diffuse color and also the material ambient color reflectivity
func (*Standard) SetEmissiveColor ¶
SetEmissiveColor sets the material emissive color The default is {0,0,0}
func (*Standard) SetOpacity ¶
SetOpacity sets the material opacity (alpha). Default is 1.0.
func (*Standard) SetShininess ¶
SetShininess sets the specular highlight factor. Default is 30.
func (*Standard) SetSpecularColor ¶
SetSpecularColor sets the material specular color reflectivity. The default is {0.5, 0.5, 0.5}