2022-01-13 05:24:03 +01:00
|
|
|
varying vec2 v_vTexcoord;
|
|
|
|
varying vec4 v_vColour;
|
|
|
|
|
2023-02-23 07:02:19 +01:00
|
|
|
#define TAU 6.283185307179586
|
2022-01-13 05:24:03 +01:00
|
|
|
#define pi1 3.14159
|
|
|
|
#define pi2 1.57079
|
|
|
|
|
2024-01-20 05:06:56 +01:00
|
|
|
uniform vec2 dimension;
|
|
|
|
uniform vec2 position;
|
2022-01-13 05:24:03 +01:00
|
|
|
uniform float angle;
|
|
|
|
|
2024-01-20 05:06:56 +01:00
|
|
|
float angle_different(in float a1, in float a2) { #region
|
2022-01-13 05:24:03 +01:00
|
|
|
float _d = (a2 - a1) + pi2;
|
|
|
|
return (_d - floor(_d / pi1) * pi1) - pi2;
|
2024-01-20 05:06:56 +01:00
|
|
|
} #endregion
|
2022-01-13 05:24:03 +01:00
|
|
|
|
|
|
|
void main() {
|
2024-01-20 05:06:56 +01:00
|
|
|
vec2 pos = v_vTexcoord;
|
|
|
|
vec2 pixel_pos = v_vTexcoord * dimension;
|
2022-01-13 05:24:03 +01:00
|
|
|
float _angle;
|
|
|
|
|
|
|
|
_angle = atan((pixel_pos.y - position.y), (pixel_pos.x - position.x)) + angle;
|
|
|
|
_angle = TAU - (_angle - floor(_angle / TAU) * TAU);
|
|
|
|
|
|
|
|
if(_angle < pi1) {
|
2024-01-20 05:06:56 +01:00
|
|
|
float _alpha = (angle + pi1) - (_angle + angle);
|
2022-01-13 05:24:03 +01:00
|
|
|
float inv_angle = (angle + pi1) + _alpha;
|
2024-01-20 05:06:56 +01:00
|
|
|
float dist = distance(pixel_pos, position);
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-01-20 05:06:56 +01:00
|
|
|
pos = (position + vec2(cos(inv_angle) * dist, -sin(inv_angle) * dist )) / dimension;
|
|
|
|
}
|
2022-01-13 05:24:03 +01:00
|
|
|
|
2024-01-20 05:06:56 +01:00
|
|
|
gl_FragColor = vec4(0.);
|
|
|
|
if(pos.x > 0. && pos.x < 1. && pos.y > 0. && pos.y < 1.)
|
|
|
|
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, pos );
|
2022-01-13 05:24:03 +01:00
|
|
|
}
|