From 86464b76e4966afb858c2302559d68cd431bdbfe Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 22 Jan 2019 20:57:13 +1100 Subject: [PATCH] made tile effect more like sphere effect --- effects/tile.frag | 22 +++++++++++++++++++--- effects/tile.xml | 8 ++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/effects/tile.frag b/effects/tile.frag index c1f48d767..5c076b647 100644 --- a/effects/tile.frag +++ b/effects/tile.frag @@ -3,14 +3,16 @@ varying vec2 vTexCoord; uniform sampler2D tex0; // scene buffer -uniform float tilecount; +uniform float scale; +uniform float centerx; +uniform float centery; uniform bool mirrorx; uniform bool mirrory; void main(void) { vec2 texCoord = vTexCoord; - vec2 coord = vec2( + /*vec2 coord = vec2( mod(vTexCoord.x*tilecount, 1.0), mod(vTexCoord.y*tilecount, 1.0) ); @@ -21,7 +23,21 @@ void main(void) { if (mirrory && mod(vTexCoord.y*tilecount, 2.0) > 1.0) { coord.y = 1.0 - coord.y; + }*/ + + float adj_scale = scale*0.01; + + vec2 scaled_coords = (vTexCoord/adj_scale); + vec2 coord = scaled_coords-vec2(0.5/adj_scale, 0.5/adj_scale)+vec2(0.5, 0.5)+vec2(-centerx*0.01, -centery*0.01); + vec2 modcoord = mod(coord, 1.0); + + if (mirrorx && mod(coord.x, 2.0) > 1.0) { + modcoord.x = 1.0 - modcoord.x; + } + + if (mirrory && mod(coord.y, 2.0) > 1.0) { + modcoord.y = 1.0 - modcoord.y; } - gl_FragColor = vec4(texture2D(tex0, coord)); + gl_FragColor = vec4(texture2D(tex0, modcoord)); } \ No newline at end of file diff --git a/effects/tile.xml b/effects/tile.xml index d73a6e79e..e002fd65d 100644 --- a/effects/tile.xml +++ b/effects/tile.xml @@ -1,7 +1,11 @@ - - + + + + + +