gg/shader.go

41 lines
646 B
Go

package gg
import (
"github.com/hajimehoshi/ebiten/v2"
//"fmt"
)
type Shader = ebiten.Shader
type ShaderOptions struct {
Shader *Shader
Uniforms map[string] any
Images [4]*Image
}
var (
// The shader is for example only.
SolidWhiteColorShader = MustNewShader([]byte(`
package main
//var Random float
func Fragment(dst vec4, src vec2, _ vec4) vec4 {
c := imageSrc0UnsafeAt(src)
return c * sin(dst.x)
}
`))
)
func MustNewShader(src []byte) (*Shader) {
shader, err := NewShader(src)
if err != nil {
panic(err)
}
return shader
}
func NewShader(src []byte) (*Shader, error) {
return ebiten.NewShader(src)
}