#version 330 core in vec2 wspTekstur; uniform sampler2D ProbnikTekstury; out vec3 kolor_out; const vec2 rozmiarOkna = vec2(800,600); const float PI = 3.1415926535; void main() { float apertura = 200.0; //srednica otworu przez ktory wpada swiatlo float polowaApertury = 0.5 * apertura * (PI / 180.0); float maxFactor = sin(polowaApertury); vec2 _wspTekstur = wspTekstur; vec2 pozycja = 2 * wspTekstur - 1; float d = length(pozycja); if (d < (2-maxFactor)) { //rownanie soczewki d = length(pozycja * maxFactor); float z = sqrt(1 - d * d); float r = atan(d, z) / PI; float phi = atan(pozycja.y, pozycja.x); _wspTekstur.x = r * cos(phi) + 0.5; _wspTekstur.y = r * sin(phi) + 0.5; } //vec3 teksel = texture(ProbnikTekstury, wspTekstur).rgb; vec3 teksel = texture(ProbnikTekstury, _wspTekstur).rgb; kolor_out = teksel; }