42 lines
647 B
Go
42 lines
647 B
Go
package gg
|
|
|
|
import (
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
//"fmt"
|
|
)
|
|
|
|
type ShaderOptions struct {
|
|
Shader *Shader
|
|
Uniforms map[string] any
|
|
Images [4]*Image
|
|
}
|
|
|
|
type Shader = ebiten.Shader
|
|
|
|
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)
|
|
}
|
|
|