mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
examples/shader: Make the chromatic berration example more readable
This commit is contained in:
parent
8aa90e60d2
commit
8bfe406470
@ -22,10 +22,10 @@ var ScreenSize vec2
|
||||
|
||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||
center := ScreenSize / 2
|
||||
amount := normalize(center-Cursor).x / 100
|
||||
amount := (center - Cursor) / texture2Size() / 10
|
||||
var clr vec3
|
||||
clr.r = texture2At(vec2(texCoord.x+amount, texCoord.y)).r
|
||||
clr.r = texture2At(vec2(texCoord.x+amount.x, texCoord.y)).r
|
||||
clr.g = texture2At(texCoord).g
|
||||
clr.b = texture2At(vec2(texCoord.x-amount, texCoord.y)).b
|
||||
clr.b = texture2At(vec2(texCoord.x-amount.x, texCoord.y)).b
|
||||
return vec4(clr, 1.0)
|
||||
}
|
||||
|
@ -3,4 +3,4 @@
|
||||
|
||||
package main
|
||||
|
||||
var chromaticaberration_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\tcenter := ScreenSize / 2\n\tamount := normalize(center-Cursor).x / 100\n\tvar clr vec3\n\tclr.r = texture2At(vec2(texCoord.x+amount, texCoord.y)).r\n\tclr.g = texture2At(texCoord).g\n\tclr.b = texture2At(vec2(texCoord.x-amount, texCoord.y)).b\n\treturn vec4(clr, 1.0)\n}\n")
|
||||
var chromaticaberration_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\tcenter := ScreenSize / 2\n\tamount := (center - Cursor) / texture2Size() / 10\n\tvar clr vec3\n\tclr.r = texture2At(vec2(texCoord.x+amount.x, texCoord.y)).r\n\tclr.g = texture2At(texCoord).g\n\tclr.b = texture2At(vec2(texCoord.x-amount.x, texCoord.y)).b\n\treturn vec4(clr, 1.0)\n}\n")
|
||||
|
Loading…
Reference in New Issue
Block a user