uniform sampler2D u_Texture0; uniform sampler2D u_Texture1; uniform sampler2D u_Texture2; varying vec2 v_TexCoords0; varying vec2 v_TexCoords1; varying vec2 v_TexCoords2; uniform float u_opacity; uniform mat4 u_colorMatrix; uniform mat4 tune360; // uniform int resolution; // 0:FHD, 1:HD, 2:SD float PI = 3.14159265358979; void main() { //gl_FragColor = pixel(v_TexCoords0.st); //return; // 최종 Dual EQ 처리된 화면 좌표 vec2 src = v_TexCoords0.st; vec2 res; vec2 center = vec2(0.0,0.0); vec2 rr = vec2(0.0,0.0); float fobx = 213.47; float foby = 101.8 * (1.0 + 0.02 *5.0); float xc = 1.7; //float blurlen = 0.02; if(resolution == 2) { fobx = 220.0 * (1.0 + -0.05 *5.0); foby = 80.0 * (1.0 + 0.05 *5.0); xc = 2.0; //float blurlen = 0.2; } // 좌측은 [N][0] 0:center X,1:rx,2 // 우측은 [N][1] 0,1,2 // 좌측 0~0.5 -> 0~1.0 으로 변경 if(v_TexCoords0.st.x < 0.5) { src.x *= 2.0; if(resolution == 2) { // -0.043600,-0.023700,-0.095750 center = vec2(0.01-0.043600,0.0); // blur 처리에 오차 발생 rr = vec2(100.0/100.0*(1.0+(-0.023700*6.0)),100.0/100.0*(1.0-0.095750)); } else { center = vec2(0.01,0.0); // blur 처리에 오차 발생 rr = vec2(1.0,1.0); } center += vec2(tune360[0][0]*0.2,tune360[1][0]*0.2); rr += vec2(tune360[2][0],tune360[3][0]); } else // 우측 0.5~1.0 -> 0~1.0 으로 변경 { src.x = (src.x-0.5) * 2.0; if(resolution == 2) { // -0.040600,-0.025600,-0.185000, center = vec2(-0.040600,0.0); rr = vec2(100.0/100.0*(1.0-0.025600*6.0),100.0/100.0*(1.0-0.185000)); } else { center = vec2(0.0,0.0); rr = vec2(1.0,1.0); } center += vec2(tune360[0][1]*0.2,tune360[1][1]*0.2); rr += vec2(tune360[2][1],tune360[3][1]); // v_TexCoords0.st.x 0.5~1.0 float accu = (v_TexCoords0.st.x - 0.5) * 2.0; // tune [0][2] 우측 가중치 변환 src.x = 0~1.0 center += vec2(tune360[0][2]*0.2*accu,tune360[1][2]*0.2*accu); // 우측 가중치 변환 (Y = 0.5) rr += vec2(tune360[2][2]*0.2*accu,tune360[3][2]*0.5*accu); } src += center; // if(resolution == 2) // { // src += vec2(tune360[0][2],tune360[1][2]); // } /* float a = 1.0; if(v_TexCoords0.st.x < blurlen) { a = 1.0 - (blurlen-v_TexCoords0.st.x)*(1.0/blurlen); } else if((1.0-v_TexCoords0.st.x) < blurlen) { a = 1.0 - (blurlen-(1.0-v_TexCoords0.st.x))*(1.0/blurlen); } else if(v_TexCoords0.st.x > 0.5 && v_TexCoords0.st.x-0.5 < blurlen) { a = 1.0 - (blurlen-(v_TexCoords0.st.x-0.5))*(1.0/blurlen); } else if(v_TexCoords0.st.x > (0.5-blurlen) && v_TexCoords0.st.x < 0.5) { a = 1.0 - (v_TexCoords0.st.x-(0.5-blurlen)) * (1.0/blurlen); } */ // 0~1 to -0.5~0.5 // Eq 2D to 3D Vector float theta = PI * (src.x - 0.5); float phi = PI * (src.y - 0.5); vec3 p = vec3(cos(phi)*sin(theta), cos(phi)*cos(theta), sin(phi)); // 3D Vector to fisheye theta = atan(p.z,p.x); phi = atan(sqrt((p.x*p.x)+(p.z*p.z)),p.y); float rx = phi / ((fobx * PI) / 180.0) / xc; float ry = phi / ((foby * PI) / 180.0); rx *= rr.x; ry *= rr.y; res = vec2(rx*cos(theta),ry*sin(theta)); //res += center; res += 0.5; // range -0.5~0.5 to 0~1.0 // 상하단 clip bool yclip = false; // 0.0~1.0 => 상/하단으로 변경 if(v_TexCoords0.st.x < 0.5) { res = vec2(res.x*2.0-0.5,res.y*0.5+0.5); yclip = res.y < 0.505 || res.y > 1.0; } else { res = vec2(res.x*2.0-0.5,res.y*0.5); yclip = res.y > 0.495 || res.y < 0.0; } bool xclip = (resolution == 2 && (res.x < 0.0 || res.x > 1.0)); // 필요없음 //bool bclip = (resolution == 2 && res.x > (0.95 + -0.014)); if(yclip) { if(v_TexCoords0.st.x < 0.5) { if(res.y < 0.505) { res = vec2(res.x,0.505); } else { res = vec2(res.x,1.0); } } else { if(res.y > 0.495) { //gl_FragColor =vec4(0.0,1.0,0.0,1.0); //return; res = vec2(res.x,0.495); } else { res = vec2(res.x,0.0+0.0001); } } //gl_FragColor =vec4(0.5,0.5,0.5,1.0); //return; } if(xclip) // || bclip { gl_FragColor =vec4(0.5,0.5,0.5,1.0); return; } /* if(a < 1.0) { // 1920x2176, 1280x1440, 720x960 vec2 resolut = vec2(1920.0,2176.0); //vec2 uv = res * resolut; gl_FragColor = effect(res,resolut,a); //gl_FragColor = blur13(res, resolut, vec2(0.5,1.0)); } else */ { gl_FragColor = clamp(u_colorMatrix * vec4(texture2D(u_Texture0, res).r, texture2D(u_Texture1, res).r, texture2D(u_Texture2, res).r,1.0), 0.0, 1.0); } }