34 lines
982 B
Go
34 lines
982 B
Go
package globject
|
|
|
|
import (
|
|
"git.wisellama.rocks/Wisellama/carpy-breakout/pkg/glshader"
|
|
"github.com/go-gl/mathgl/mgl32"
|
|
)
|
|
|
|
// PointLight implements a specifically position light source where
|
|
// light radiates out in all directions and fades away the further
|
|
// away you get.
|
|
type PointLight struct {
|
|
Position mgl32.Vec3
|
|
AmbientColor mgl32.Vec4
|
|
DiffuseColor mgl32.Vec4
|
|
SpecularColor mgl32.Vec4
|
|
}
|
|
|
|
func NewPointLight(position mgl32.Vec3) *PointLight {
|
|
d := PointLight{
|
|
Position: position,
|
|
AmbientColor: mgl32.Vec4{0.2, 0.2, 0.2, 1},
|
|
DiffuseColor: mgl32.Vec4{1, 1, 1, 1},
|
|
SpecularColor: mgl32.Vec4{1, 1, 1, 1},
|
|
}
|
|
return &d
|
|
}
|
|
|
|
func (l *PointLight) GLInit(glProgram uint32) {
|
|
glshader.SetUniformVec3f(glProgram, "light.position", l.Position)
|
|
glshader.SetUniformVec4f(glProgram, "light.ambient", l.AmbientColor)
|
|
glshader.SetUniformVec4f(glProgram, "light.diffuse", l.DiffuseColor)
|
|
glshader.SetUniformVec4f(glProgram, "light.specular", l.SpecularColor)
|
|
}
|