mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
parent
08270ee729
commit
95022ff1a5
@ -36,6 +36,7 @@
|
||||
//go:generate file2byteslice -package=shader -input=./images/shader/gopher.png -output=./images/shader/gopher.go -var=Gopher_png
|
||||
//go:generate file2byteslice -package=shader -input=./images/shader/gopherbg.png -output=./images/shader/gopherbg.go -var=GopherBg_png
|
||||
//go:generate file2byteslice -package=shader -input=./images/shader/normal.png -output=./images/shader/normal.go -var=Normal_png
|
||||
//go:generate file2byteslice -package=shader -input=./images/shader/noise.png -output=./images/shader/noise.go -var=Noise_png
|
||||
//go:generate file2byteslice -package=platformer -input=./images/platformer/background.png -output=./images/platformer/background.go -var=Background_png
|
||||
//go:generate file2byteslice -package=platformer -input=./images/platformer/left.png -output=./images/platformer/left.go -var=Left_png
|
||||
//go:generate file2byteslice -package=platformer -input=./images/platformer/mainchar.png -output=./images/platformer/mainchar.go -var=MainChar_png
|
||||
|
@ -117,6 +117,13 @@ By Håkan Svensson Xauxa
|
||||
The Creative Commons Attribution-Share Alike 3.0 Unported license
|
||||
```
|
||||
|
||||
## shader/noise.png
|
||||
|
||||
```
|
||||
Generated by Magnus Wahlstrand (https://github.com/kyeett)
|
||||
MIT License
|
||||
```
|
||||
|
||||
## Other image files
|
||||
|
||||
```
|
||||
|
6
examples/resources/images/shader/noise.go
Normal file
6
examples/resources/images/shader/noise.go
Normal file
File diff suppressed because one or more lines are too long
BIN
examples/resources/images/shader/noise.png
Normal file
BIN
examples/resources/images/shader/noise.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 162 KiB |
35
examples/shader/dissolve.go
Normal file
35
examples/shader/dissolve.go
Normal file
@ -0,0 +1,35 @@
|
||||
// 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 ScreenImage vec2
|
||||
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
// Triangle wave to go 0-->1-->0...
|
||||
limit := abs(2*fract(Time/3) - 1)
|
||||
level := image3TextureAt(texCoord).x
|
||||
|
||||
// Add a white border
|
||||
if limit-0.1 < level && level < limit {
|
||||
alpha := image0TextureAt(texCoord).w
|
||||
return vec4(alpha)
|
||||
}
|
||||
|
||||
return step(limit, level) * image0TextureAt(texCoord)
|
||||
}
|
6
examples/shader/dissolve_go.go
Normal file
6
examples/shader/dissolve_go.go
Normal file
@ -0,0 +1,6 @@
|
||||
// Code generated by file2byteslice. DO NOT EDIT.
|
||||
// (gofmt is fine after generating)
|
||||
|
||||
package main
|
||||
|
||||
var dissolve_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 ScreenImage vec2\n\nfunc Fragment(position vec4, texCoord vec2, color vec4) vec4 {\n\t// Triangle wave to go 0-->1-->0...\n\tlimit := abs(2*fract(Time/3) - 1)\n\tlevel := image3TextureAt(texCoord).x\n\n\t// Add a white border\n\tif limit-0.1 < level && level < limit {\n\t\talpha := image0TextureAt(texCoord).w\n\t\treturn vec4(alpha)\n\t}\n\n\treturn step(limit, level) * image0TextureAt(texCoord)\n}\n")
|
@ -18,3 +18,4 @@ package main
|
||||
//go:generate file2byteslice -package=main -input=lighting.go -output=lighting_go.go -var=lighting_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=dissolve.go -output=dissolve_go.go -var=dissolve_go
|
||||
|
@ -37,6 +37,7 @@ var (
|
||||
gopherImage *ebiten.Image
|
||||
gopherBgImage *ebiten.Image
|
||||
normalImage *ebiten.Image
|
||||
noiseImage *ebiten.Image
|
||||
)
|
||||
|
||||
func init() {
|
||||
@ -72,11 +73,20 @@ func init() {
|
||||
normalImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
func init() {
|
||||
img, _, err := image.Decode(bytes.NewReader(resources.Noise_png))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
noiseImage, _ = ebiten.NewImageFromImage(img, ebiten.FilterDefault)
|
||||
}
|
||||
|
||||
var shaderSrcs = [][]byte{
|
||||
default_go,
|
||||
lighting_go,
|
||||
radialblur_go,
|
||||
chromaticaberration_go,
|
||||
dissolve_go,
|
||||
}
|
||||
|
||||
type Game struct {
|
||||
@ -127,6 +137,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
|
||||
op.Images[0] = gopherImage
|
||||
op.Images[1] = normalImage
|
||||
op.Images[2] = gopherBgImage
|
||||
op.Images[3] = noiseImage
|
||||
screen.DrawRectShader(w, h, s, op)
|
||||
|
||||
msg := "Press Up/Down to switch the shader."
|
||||
|
Loading…
Reference in New Issue
Block a user