mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-27 11:12:44 +01:00
parent
c6282e1cfc
commit
2fb5108bbe
@ -19,10 +19,8 @@ package main
|
|||||||
var Time float
|
var Time float
|
||||||
var Cursor vec2
|
var Cursor vec2
|
||||||
|
|
||||||
// viewportSize is a predefined function.
|
|
||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
pos := position.xy/viewportSize() + Cursor/viewportSize()/4
|
pos := position.xy/textureDstSize() + Cursor/textureDstSize()/4
|
||||||
clr := 0.0
|
clr := 0.0
|
||||||
clr += sin(pos.x*cos(Time/15)*80) + cos(pos.y*cos(Time/15)*10)
|
clr += sin(pos.x*cos(Time/15)*80) + cos(pos.y*cos(Time/15)*10)
|
||||||
clr += sin(pos.y*sin(Time/10)*40) + cos(pos.x*sin(Time/25)*40)
|
clr += sin(pos.y*sin(Time/10)*40) + cos(pos.x*sin(Time/25)*40)
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
var default_go = []byte("// Copyright 2020 The Ebiten Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// +build ignore\n\npackage main\n\nvar Time float\nvar Cursor vec2\n\n// viewportSize is a predefined function.\n\nfunc Fragment(position vec4, texCoord vec2, color vec4) vec4 {\n\tpos := position.xy/viewportSize() + Cursor/viewportSize()/4\n\tclr := 0.0\n\tclr += sin(pos.x*cos(Time/15)*80) + cos(pos.y*cos(Time/15)*10)\n\tclr += sin(pos.y*sin(Time/10)*40) + cos(pos.x*sin(Time/25)*40)\n\tclr += sin(pos.x*sin(Time/5)*10) + sin(pos.y*sin(Time/35)*80)\n\tclr *= sin(Time/10) * 0.5\n\treturn vec4(clr, clr*0.5, sin(clr+Time/3)*0.75, 1)\n}\n")
|
var default_go = []byte("// Copyright 2020 The Ebiten Authors\n//\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\n// +build ignore\n\npackage main\n\nvar Time float\nvar Cursor vec2\n\nfunc Fragment(position vec4, texCoord vec2, color vec4) vec4 {\n\tpos := position.xy/textureDstSize() + Cursor/textureDstSize()/4\n\tclr := 0.0\n\tclr += sin(pos.x*cos(Time/15)*80) + cos(pos.y*cos(Time/15)*10)\n\tclr += sin(pos.y*sin(Time/10)*40) + cos(pos.x*sin(Time/25)*40)\n\tclr += sin(pos.x*sin(Time/5)*10) + sin(pos.y*sin(Time/35)*80)\n\tclr *= sin(Time/10) * 0.5\n\treturn vec4(clr, clr*0.5, sin(clr+Time/3)*0.75, 1)\n}\n")
|
||||||
|
10
shader.go
10
shader.go
@ -29,16 +29,16 @@ var shaderSuffix string
|
|||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
shaderSuffix = `
|
shaderSuffix = `
|
||||||
var __viewportSize vec2
|
var __textureDstSize vec2
|
||||||
|
|
||||||
func viewportSize() vec2 {
|
func textureDstSize() vec2 {
|
||||||
return __viewportSize
|
return __textureDstSize
|
||||||
}
|
}
|
||||||
|
|
||||||
func __vertex(position vec2, texCoord vec2, color vec4) (vec4, vec2, vec4) {
|
func __vertex(position vec2, texCoord vec2, color vec4) (vec4, vec2, vec4) {
|
||||||
return mat4(
|
return mat4(
|
||||||
2/viewportSize().x, 0, 0, 0,
|
2/textureDstSize().x, 0, 0, 0,
|
||||||
0, 2/viewportSize().y, 0, 0,
|
0, 2/textureDstSize().y, 0, 0,
|
||||||
0, 0, 1, 0,
|
0, 0, 1, 0,
|
||||||
-1, -1, 0, 1,
|
-1, -1, 0, 1,
|
||||||
) * vec4(position, 0, 1), texCoord, color
|
) * vec4(position, 0, 1), texCoord, color
|
||||||
|
Loading…
Reference in New Issue
Block a user