forked from exeldro/obs-lua
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fisheye.shader
22 lines (21 loc) · 843 Bytes
/
fisheye.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
uniform int center_x_percent = 50;
uniform int center_y_percent = 50;
uniform float power = 1.75;
float4 mainImage(VertData v_in) : TARGET
{
float2 center_pos = float2(center_x_percent * .01, center_y_percent * .01);
float2 uv = v_in.uv;
if (power >= 0.0001){
float b = sqrt(dot(center_pos, center_pos));
uv = center_pos + normalize(v_in.uv - center_pos) * tan(distance(center_pos, v_in.uv) * power) * b / tan( b * power);
} else if(power <= -0.0001){
float b;
if (uv_pixel_interval.x < uv_pixel_interval.y){
b = center_pos.x;
} else {
b = center_pos.y;
}
uv = center_pos + normalize(v_in.uv - center_pos) * atan(distance(center_pos, v_in.uv) * -power * 10.0) * b / atan(-power * b * 10.0);
}
return image.Sample(textureSampler, uv);
}