2023-10-23 15:45:18 +03:00
|
|
|
package gg
|
2023-05-22 23:39:01 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hajimehoshi/ebiten/v2"
|
|
|
|
//"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Shader = ebiten.Shader
|
2023-05-25 00:42:48 +03:00
|
|
|
type ShaderOptions struct {
|
2023-05-27 18:00:27 +03:00
|
|
|
Shader *Shader
|
2023-05-25 00:42:48 +03:00
|
|
|
Uniforms map[string] any
|
|
|
|
Images [4]*Image
|
|
|
|
}
|
2023-05-22 23:39:01 +03:00
|
|
|
|
|
|
|
var (
|
2023-05-23 22:42:35 +03:00
|
|
|
// The shader is for example only.
|
2023-05-23 16:19:55 +03:00
|
|
|
SolidWhiteColorShader = MustNewShader([]byte(`
|
2023-05-22 23:39:01 +03:00
|
|
|
package main
|
|
|
|
|
2024-01-17 09:36:08 +03:00
|
|
|
//var Random float
|
2023-05-27 18:00:27 +03:00
|
|
|
|
2024-01-17 09:36:08 +03:00
|
|
|
func Fragment(dst vec4, src vec2, _ vec4) vec4 {
|
|
|
|
c := imageSrc0UnsafeAt(src)
|
2024-01-21 13:35:40 +03:00
|
|
|
return c * sin(dst.x)
|
2023-05-22 23:39:01 +03:00
|
|
|
}
|
|
|
|
`))
|
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|