mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +01:00
examples/shader: bug fix: use pixels instead of texels for offsets
Closes #2483
This commit is contained in:
parent
89c64f83e3
commit
760e6b9ebd
@ -21,16 +21,18 @@ var Cursor vec2
|
|||||||
var ScreenSize vec2
|
var ScreenSize vec2
|
||||||
|
|
||||||
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
func Fragment(position vec4, texCoord vec2, color vec4) vec4 {
|
||||||
border := ScreenSize.y*0.6 + 4*cos(Time*3+texCoord.y*200)
|
srcsize := imageSrcTextureSize()
|
||||||
|
ypx := texCoord.y * srcsize.y
|
||||||
|
|
||||||
|
border := ScreenSize.y*0.6 + 4*cos(Time*3+ypx/10)
|
||||||
if position.y < border {
|
if position.y < border {
|
||||||
return imageSrc2UnsafeAt(texCoord)
|
return imageSrc2UnsafeAt(texCoord)
|
||||||
}
|
}
|
||||||
|
|
||||||
srcsize := imageSrcTextureSize()
|
|
||||||
rorigin, _ := imageSrcRegionOnTexture()
|
rorigin, _ := imageSrcRegionOnTexture()
|
||||||
|
|
||||||
xoffset := (4 / srcsize.x) * cos(Time*3+texCoord.y*200)
|
xoffset := (4 / srcsize.x) * cos(Time*3+ypx/10)
|
||||||
yoffset := (20 / srcsize.y) * (1.0 + cos(Time*3+texCoord.y*50))
|
yoffset := (20 / srcsize.y) * (1.0 + cos(Time*3+ypx/40))
|
||||||
bordertex := border / srcsize.y
|
bordertex := border / srcsize.y
|
||||||
clr := imageSrc2At(vec2(
|
clr := imageSrc2At(vec2(
|
||||||
texCoord.x+xoffset,
|
texCoord.x+xoffset,
|
||||||
|
Loading…
Reference in New Issue
Block a user