curved screen
in
Programming Questions
•
2 years ago
hi!
i'm using a curved screen of 250 cm by 500 cm with an angle of 160 degrees and i want to bend the output of Processing, so that it fits. I've found a fisheye exemple of GLgraphics and i want to change this to my arc-ed screen. How can i do this correctly?
- uniform sampler2D texture0;
- uniform float aperture;
- const float PI = 3.1415926535;
- void main(void) {
- float apertureHalf = 0.5 * aperture * (PI / 180.0);
- // This factor ajusts the coordinates in the case that
- // the aperture angle is less than 180 degrees, in which
- // case the area displayed is not the entire half-sphere.
- float maxFactor = sin(apertureHalf);
- vec2 pos = 2.0 * gl_TexCoord[0].st - 1.0;
- float l = length(pos);
- if (l > 1.0) {
- gl_FragColor = vec4(0, 0, 0, 1);
- } else {
- float x = maxFactor * pos.x;
- float y = maxFactor * pos.y;
- float n = length(vec2(x, y));
- float z = sqrt(1.0 - n * n);
- float r = atan(n, z) / PI;
- float phi = atan(y, x);
- float u = r * cos(phi) + 0.5;
- float v = r * sin(phi) + 0.5;
- gl_FragColor = texture2D(texture0, vec2(u, v));
- }
- }
1