From 1c14ba8eeb866c93d707b9ffc92c211dcec0c64e Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Thu, 13 Apr 2023 14:16:53 +0900 Subject: [PATCH] examples/shader: add comments Updates #1431 --- examples/shader/chromaticaberration.go | 2 ++ examples/shader/water.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/examples/shader/chromaticaberration.go b/examples/shader/chromaticaberration.go index bbdfeb0c7..073b79ab4 100644 --- a/examples/shader/chromaticaberration.go +++ b/examples/shader/chromaticaberration.go @@ -22,6 +22,8 @@ var ScreenSize vec2 func Fragment(position vec4, texCoord vec2, color vec4) vec4 { center := ScreenSize / 2 + // Convert a pixel to a texel by dividing by the texture size. + // TODO: This is confusing. Add a function to treat pixels (#1431). amount := (center - Cursor) / 10 / imageSrcTextureSize() var clr vec3 clr.r = imageSrc2At(texCoord + amount).r diff --git a/examples/shader/water.go b/examples/shader/water.go index 2db09b5f5..2dbfd93be 100644 --- a/examples/shader/water.go +++ b/examples/shader/water.go @@ -30,6 +30,8 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 { return imageSrc2UnsafeAt(texCoord) } + // Convert a pixel to a texel by dividing by the texture size. + // TODO: This is confusing. Add a function to treat pixels (#1431). srcTexSize := imageSrcTextureSize() xoffset := (4 / srcTexSize.x) * cos(Time*3+pos.y/10) yoffset := (20 / srcTexSize.y) * (1.0 + cos(Time*3+pos.y/40))