mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 19:28:57 +01:00
parent
a67fd4a2b3
commit
a1d278b097
@ -19,3 +19,4 @@ package main
|
|||||||
//go:generate file2byteslice -package=main -input=radialblur.go -output=radialblur_go.go -var=radialblur_go
|
//go:generate file2byteslice -package=main -input=radialblur.go -output=radialblur_go.go -var=radialblur_go
|
||||||
//go:generate file2byteslice -package=main -input=chromaticaberration.go -output=chromaticaberration_go.go -var=chromaticaberration_go
|
//go:generate file2byteslice -package=main -input=chromaticaberration.go -output=chromaticaberration_go.go -var=chromaticaberration_go
|
||||||
//go:generate file2byteslice -package=main -input=dissolve.go -output=dissolve_go.go -var=dissolve_go
|
//go:generate file2byteslice -package=main -input=dissolve.go -output=dissolve_go.go -var=dissolve_go
|
||||||
|
//go:generate file2byteslice -package=main -input=water.go -output=water_go.go -var=water_go
|
||||||
|
@ -87,6 +87,7 @@ var shaderSrcs = [][]byte{
|
|||||||
radialblur_go,
|
radialblur_go,
|
||||||
chromaticaberration_go,
|
chromaticaberration_go,
|
||||||
dissolve_go,
|
dissolve_go,
|
||||||
|
water_go,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
|
42
examples/shader/water.go
Normal file
42
examples/shader/water.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Copyright 2020 The Ebiten Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
// +build ignore
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
var Time float
|
||||||
|
var Cursor vec2
|
||||||
|
var ScreenSize vec2
|
||||||
|
|
||||||
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
|
border := ScreenSize.y*0.6 + 4*cos(Time*3+texCoord.y*200)
|
||||||
|
if position.y < border {
|
||||||
|
return image2TextureAt(texCoord)
|
||||||
|
}
|
||||||
|
|
||||||
|
srcsize := imageSrcTextureSize()
|
||||||
|
rorigin, rsize := imageSrcTextureSourceRegion()
|
||||||
|
|
||||||
|
xoffset := (4 / srcsize.x) * cos(Time*3+texCoord.y*200)
|
||||||
|
yoffset := (20 / srcsize.y) * (1.0 + cos(Time*3+texCoord.y*50))
|
||||||
|
bordertex := border / srcsize.y
|
||||||
|
clr := vec4(image2TextureBoundsAt(vec2(
|
||||||
|
texCoord.x+xoffset,
|
||||||
|
-(texCoord.y+yoffset-rorigin.y)+bordertex*2+rorigin.y,
|
||||||
|
)))
|
||||||
|
|
||||||
|
overlay := vec4(0.5, 1, 1, 1)
|
||||||
|
return mix(clr, overlay, 0.25)
|
||||||
|
}
|
5
examples/shader/water_go.go
Normal file
5
examples/shader/water_go.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
// Code generated by file2byteslice. DO NOT EDIT.
|
||||||
|
|
||||||
|
package main
|
||||||
|
|
||||||
|
var water_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\nvar ScreenSize vec2\n\nfunc Fragment(position vec4, texCoord vec2, color vec4) vec4 {\n\tborder := ScreenSize.y*0.6 + 4*cos(Time*3+texCoord.y*200)\n\tif position.y < border {\n\t\treturn image2TextureAt(texCoord)\n\t}\n\n\tsrcsize := imageSrcTextureSize()\n\trorigin, rsize := imageSrcTextureSourceRegion()\n\n\txoffset := (4 / srcsize.x) * cos(Time*3+texCoord.y*200)\n\tyoffset := (20 / srcsize.y) * (1.0 + cos(Time*3+texCoord.y*50))\n\tbordertex := border / srcsize.y\n\tclr := vec4(image2TextureBoundsAt(vec2(\n\t\ttexCoord.x+xoffset,\n\t\t-(texCoord.y+yoffset-rorigin.y)+bordertex*2+rorigin.y,\n\t)))\n\n\toverlay := vec4(0.5, 1, 1, 1)\n\treturn mix(clr, overlay, 0.25)\n}\n")
|
Loading…
Reference in New Issue
Block a user