examples/shader: refactoring

This commit is contained in:
Hajime Hoshi 2023-04-23 16:29:23 +09:00
parent 00e45affe9
commit 01bb42526a
2 changed files with 2 additions and 2 deletions

View File

@ -29,5 +29,5 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
clr.r = imageSrc2At(texCoord + amount).r clr.r = imageSrc2At(texCoord + amount).r
clr.g = imageSrc2UnsafeAt(texCoord).g clr.g = imageSrc2UnsafeAt(texCoord).g
clr.b = imageSrc2At(texCoord - amount).b clr.b = imageSrc2At(texCoord - amount).b
return vec4(clr, 1.0) return vec4(clr, 1)
} }

View File

@ -34,7 +34,7 @@ func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
// TODO: This is confusing. Add a function to treat pixels (#1431). // TODO: This is confusing. Add a function to treat pixels (#1431).
srcTexSize := imageSrcTextureSize() srcTexSize := imageSrcTextureSize()
xoffset := (4 / srcTexSize.x) * cos(Time*3+pos.y/10) xoffset := (4 / srcTexSize.x) * cos(Time*3+pos.y/10)
yoffset := (20 / srcTexSize.y) * (1.0 + cos(Time*3+pos.y/40)) yoffset := (20 / srcTexSize.y) * (1 + cos(Time*3+pos.y/40))
bordertex := border / srcTexSize.y bordertex := border / srcTexSize.y
clr := imageSrc2At(vec2( clr := imageSrc2At(vec2(
texCoord.x+xoffset, texCoord.x+xoffset,