From 05a1c2faa12be88f8fefe5b5a660f19b48ae4cb6 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 16 Aug 2020 02:34:18 +0900 Subject: [PATCH] examples/shader: Always use 1 for an alpha This is necessary to keep the color pre-multiplied --- examples/shader/water.go | 8 ++++---- examples/shader/water_go.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/examples/shader/water.go b/examples/shader/water.go index ad37bd038..39265aeca 100644 --- a/examples/shader/water.go +++ b/examples/shader/water.go @@ -32,11 +32,11 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { 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( + clr := image2TextureBoundsAt(vec2( texCoord.x+xoffset, -(texCoord.y+yoffset-rorigin.y)+bordertex*2+rorigin.y, - ))) + )).rgb - overlay := vec4(0.5, 1, 1, 1) - return mix(clr, overlay, 0.25) + overlay := vec3(0.5, 1, 1) + return vec4(mix(clr, overlay, 0.25), 1) } diff --git a/examples/shader/water_go.go b/examples/shader/water_go.go index 42ea2e4a8..96aeb3d2c 100644 --- a/examples/shader/water_go.go +++ b/examples/shader/water_go.go @@ -2,4 +2,4 @@ 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") +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 := image2TextureBoundsAt(vec2(\n\t\ttexCoord.x+xoffset,\n\t\t-(texCoord.y+yoffset-rorigin.y)+bordertex*2+rorigin.y,\n\t)).rgb\n\n\toverlay := vec3(0.5, 1, 1)\n\treturn vec4(mix(clr, overlay, 0.25), 1)\n}\n")