32 lines
1009 B
Go
32 lines
1009 B
Go
package globject
|
|
|
|
import (
|
|
"git.wisellama.rocks/Wisellama/carpy-breakout/pkg/glshader"
|
|
"github.com/go-gl/mathgl/mgl32"
|
|
)
|
|
|
|
// DirectionalLight implements effectively an infinitely far away point light.
|
|
type DirectionalLight struct {
|
|
Direction mgl32.Vec3 // the direction the light is travelling from the sun
|
|
AmbientColor mgl32.Vec4
|
|
DiffuseColor mgl32.Vec4
|
|
SpecularColor mgl32.Vec4
|
|
}
|
|
|
|
func NewDirectionalLight(direction mgl32.Vec3) *DirectionalLight {
|
|
d := DirectionalLight{
|
|
Direction: direction,
|
|
AmbientColor: mgl32.Vec4{0.1, 0.1, 0.1, 1},
|
|
DiffuseColor: mgl32.Vec4{1, 1, 1, 1},
|
|
SpecularColor: mgl32.Vec4{1, 1, 1, 1},
|
|
}
|
|
return &d
|
|
}
|
|
|
|
func (l *DirectionalLight) GLInit(glProgram uint32) {
|
|
glshader.SetUniformVec3f(glProgram, "dirLight.direction", l.Direction)
|
|
glshader.SetUniformVec4f(glProgram, "dirLight.ambient", l.AmbientColor)
|
|
glshader.SetUniformVec4f(glProgram, "dirLight.diffuse", l.DiffuseColor)
|
|
glshader.SetUniformVec4f(glProgram, "dirLight.specular", l.SpecularColor)
|
|
}
|