first commit
This commit is contained in:
137
project/fm_viewer/fav/shaders/defish2.fsh
Normal file
137
project/fm_viewer/fav/shaders/defish2.fsh
Normal file
@@ -0,0 +1,137 @@
|
||||
uniform sampler2D u_Texture0;
|
||||
uniform sampler2D u_Texture1;
|
||||
uniform sampler2D u_Texture2;
|
||||
// TOP DOWN 360 MODEL
|
||||
// https://github.com/tokoik/fisheye ...
|
||||
// https://stackoverflow.com/questions/39352533/android-opengl-es-textured-half-sphere ???
|
||||
varying vec2 v_TexCoords0;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
|
||||
#define v_TexCoords1 v_TexCoords0
|
||||
#define v_TexCoords2 v_TexCoords0
|
||||
#define v_TexCoords3 v_TexCoords0
|
||||
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_colorMatrix;
|
||||
|
||||
uniform int u_mode;
|
||||
uniform float u_angle;
|
||||
uniform int u_flip;
|
||||
uniform float u_effectiveWidth;
|
||||
uniform float u_clipBound;
|
||||
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fc = v_TexCoords0.st;
|
||||
float PI = 3.141592;
|
||||
|
||||
// FLIP 반전
|
||||
// if(u_mode != 2 && u_flip == 1) {
|
||||
// fc.y = 1.0 - fc.y;
|
||||
// }
|
||||
|
||||
// VR + PANORAMA
|
||||
// #if (REMOVE_360_WIDE_SINGLE)
|
||||
//if(u_mode == 3 || u_mode == 1)
|
||||
if(u_mode == 2 || u_mode == 3)
|
||||
{
|
||||
float R = u_effectiveWidth / 2.0 * 0.96;//0.5;
|
||||
float Cfx = u_effectiveWidth / 2.0;
|
||||
float Cfy = 0.5;
|
||||
|
||||
float He = 1.0;
|
||||
float We = u_effectiveWidth;
|
||||
|
||||
float Xe = 1.0-fc.x; // flip h
|
||||
float Ye = 1.0-fc.y; // upside down
|
||||
|
||||
if(u_mode == 3){
|
||||
if(Ye > 0.62) {
|
||||
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||
return;
|
||||
}
|
||||
Ye = (Ye / 0.62);
|
||||
}
|
||||
|
||||
float r = Ye/He*R;
|
||||
float theta = Xe/We*2.0*PI;// - (u_angle * 3.0); // TOP_DOWN_2D_360
|
||||
float Xf = Cfx+r*sin(theta);
|
||||
float Yf = Cfy+r*cos(theta);
|
||||
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
else if(u_mode == 1) // PANORAMA 2CH
|
||||
{
|
||||
fc.y = 1.0 - fc.y;
|
||||
|
||||
float Hf = 1.0;
|
||||
float R = u_effectiveWidth / 2.0 * 0.99;
|
||||
float Cfx = u_effectiveWidth / 2.0;
|
||||
float Cfy = 0.5;
|
||||
|
||||
float He = 1.0;
|
||||
float We = u_effectiveWidth;
|
||||
|
||||
float Xe = 1.0-fc.x; // flip h
|
||||
float Ye = 1.0-fc.y; // upside down
|
||||
|
||||
if(fc.y < 0.5) // top (0~180 -> bottom
|
||||
{
|
||||
Ye = 1.0-Ye;
|
||||
|
||||
float scale = (Ye + 0.5) * 2.0; // 0.0~0.5 = 1.0~2.0
|
||||
float r = ((Ye/He*R)+0.25) / scale;
|
||||
float theta = Xe/We*PI+(PI/2.0); // 1/2
|
||||
theta += PI;
|
||||
float Xf = Cfx+r*sin(theta) * scale * 1.0;
|
||||
float Yf = Cfy+r*cos(theta) * scale;
|
||||
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
else // bottom 180 ~ 360
|
||||
{
|
||||
Ye = 1.0-Ye-0.5;
|
||||
float scale = (Ye + 0.5) * 2.0; // 0.0~0.5 = 1.0~2.0
|
||||
float r = ((Ye/He*R)+0.25) / scale;
|
||||
float theta = Xe/We*PI+(PI/2.0); // 1/2
|
||||
float Xf = Cfx+r*sin(theta) * scale;
|
||||
float Yf = Cfy+r*cos(theta) * scale;
|
||||
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
|
||||
if(u_clipBound > 0.0) {
|
||||
//if(v_TexCoords0.st.x < u_clipBound || v_TexCoords0.st.x > (1.0 - u_clipBound))
|
||||
if(v_TexCoords0.st.x < 0.0 || v_TexCoords0.st.x > 1.0)
|
||||
{
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(texture2D(u_Texture0, fc).r,
|
||||
texture2D(u_Texture1, fc).r,
|
||||
texture2D(u_Texture2, fc).r,
|
||||
1.0) * 0.9, 0.0, 1.0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else // CLIP ZOOM
|
||||
{
|
||||
// ZOOM CLIP
|
||||
if (fc.x < 0.0 || fc.x > 1.0) {
|
||||
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||
return;
|
||||
}
|
||||
fc.x *= u_effectiveWidth;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(texture2D(u_Texture0, fc).r,
|
||||
texture2D(u_Texture1, fc).r,
|
||||
texture2D(u_Texture2, fc).r,
|
||||
1.0), 0.0, 1.0);
|
||||
|
||||
}
|
||||
50
project/fm_viewer/fav/shaders/defish2.vsh
Normal file
50
project/fm_viewer/fav/shaders/defish2.vsh
Normal file
@@ -0,0 +1,50 @@
|
||||
/******************************************************************************
|
||||
QtAV: Multimedia framework based on Qt and FFmpeg
|
||||
Copyright (C) 2015 Wang Bin <wbsecg1@gmail.com>
|
||||
|
||||
* This file is part of QtAV
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
******************************************************************************/
|
||||
// TOP DOWN 360 MODEL
|
||||
attribute vec4 a_Position;
|
||||
attribute vec2 a_TexCoords0;
|
||||
uniform mat4 u_Matrix;
|
||||
varying vec2 v_TexCoords0;
|
||||
#ifdef MULTI_COORD
|
||||
attribute vec2 a_TexCoords1;
|
||||
attribute vec2 a_TexCoords2;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
#ifdef HAS_ALPHA
|
||||
attribute vec2 a_TexCoords3;
|
||||
varying vec2 v_TexCoords3;
|
||||
#endif
|
||||
#endif //MULTI_COORD
|
||||
|
||||
/***User header code***%userHeader%***/
|
||||
|
||||
void main() {
|
||||
gl_Position = u_Matrix * a_Position;
|
||||
v_TexCoords0 = a_TexCoords0;
|
||||
|
||||
#ifdef MULTI_COORD
|
||||
v_TexCoords1 = a_TexCoords1;
|
||||
v_TexCoords2 = a_TexCoords2;
|
||||
#ifdef HAS_ALPHA
|
||||
v_TexCoords3 = a_TexCoords3;
|
||||
#endif
|
||||
#endif //MULTI_COORD
|
||||
}
|
||||
139
project/fm_viewer/fav/shaders/defish2d.fsh
Normal file
139
project/fm_viewer/fav/shaders/defish2d.fsh
Normal file
@@ -0,0 +1,139 @@
|
||||
uniform sampler2D u_Texture0;
|
||||
uniform sampler2D u_Texture1;
|
||||
uniform sampler2D u_Texture2;
|
||||
// TOP DOWN 360 MODEL
|
||||
// https://github.com/tokoik/fisheye ...
|
||||
// https://stackoverflow.com/questions/39352533/android-opengl-es-textured-half-sphere ???
|
||||
varying vec2 v_TexCoords0;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
|
||||
#define v_TexCoords1 v_TexCoords0
|
||||
#define v_TexCoords2 v_TexCoords0
|
||||
#define v_TexCoords3 v_TexCoords0
|
||||
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_colorMatrix;
|
||||
|
||||
uniform int u_mode;
|
||||
uniform float u_angle;
|
||||
uniform int u_flip;
|
||||
uniform float u_effectiveWidth;
|
||||
uniform float u_clipBound;
|
||||
uniform float u_whratio;
|
||||
void main(void)
|
||||
{
|
||||
vec2 fc = v_TexCoords0.st;
|
||||
float PI = 3.141592;
|
||||
|
||||
// FLIP 반전
|
||||
// if(u_mode != 2 && u_flip == 1) {
|
||||
// fc.y = 1.0 - fc.y;
|
||||
// }
|
||||
|
||||
// VR + PANORAMA
|
||||
// #if (REMOVE_360_WIDE_SINGLE)
|
||||
//if(u_mode == 3 || u_mode == 1)
|
||||
if(u_mode == 2 || u_mode == 3)
|
||||
{
|
||||
float R = u_effectiveWidth / 2.0 * 0.99;//0.5;
|
||||
float Cfx = u_effectiveWidth / 2.0;
|
||||
float Cfy = 0.5;
|
||||
|
||||
float He = 1.0;
|
||||
float We = u_effectiveWidth;
|
||||
|
||||
float Xe = 1.0-fc.x; // flip h
|
||||
float Ye = 1.0-fc.y; // upside down
|
||||
|
||||
// if(u_mode == 3){
|
||||
// if(Ye > 0.62) {
|
||||
// gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||
// return;
|
||||
// }
|
||||
// Ye = (Ye / 0.62);
|
||||
// }
|
||||
|
||||
float r = Ye/He*R;
|
||||
float theta = Xe/We*2.0*PI - (u_angle * 3.0); // TOP_DOWN_2D_360
|
||||
|
||||
theta = theta * 0.2 * u_whratio;
|
||||
|
||||
float Xf = Cfx+r*sin(theta);
|
||||
float Yf = Cfy+r*cos(theta);
|
||||
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
else if(u_mode == 1) // PANORAMA 2CH
|
||||
{
|
||||
fc.y = 1.0 - fc.y;
|
||||
|
||||
float Hf = 1.0;
|
||||
float R = u_effectiveWidth / 2.0 * 0.99;
|
||||
float Cfx = u_effectiveWidth / 2.0;
|
||||
float Cfy = 0.5;
|
||||
|
||||
float He = 1.0;
|
||||
float We = u_effectiveWidth;
|
||||
|
||||
float Xe = 1.0-fc.x; // flip h
|
||||
float Ye = 1.0-fc.y; // upside down
|
||||
|
||||
if(fc.y < 0.5) // top (0~180 -> bottom
|
||||
{
|
||||
Ye = 1.0-Ye;
|
||||
|
||||
float scale = (Ye + 0.5) * 2.0; // 0.0~0.5 = 1.0~2.0
|
||||
float r = ((Ye/He*R)+0.25) / scale;
|
||||
float theta = Xe/We*PI+(PI/2.0); // 1/2
|
||||
theta += PI;
|
||||
float Xf = Cfx+r*sin(theta) * scale * 1.0;
|
||||
float Yf = Cfy+r*cos(theta) * scale;
|
||||
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
else // bottom 180 ~ 360
|
||||
{
|
||||
Ye = 1.0-Ye-0.5;
|
||||
float scale = (Ye + 0.5) * 2.0; // 0.0~0.5 = 1.0~2.0
|
||||
float r = ((Ye/He*R)+0.25) / scale;
|
||||
float theta = Xe/We*PI+(PI/2.0); // 1/2
|
||||
float Xf = Cfx+r*sin(theta) * scale;
|
||||
float Yf = Cfy+r*cos(theta) * scale;
|
||||
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
|
||||
if(u_clipBound > 0.0) {
|
||||
//if(v_TexCoords0.st.x < u_clipBound || v_TexCoords0.st.x > (1.0 - u_clipBound))
|
||||
if(v_TexCoords0.st.x < 0.0 || v_TexCoords0.st.x > 1.0)
|
||||
{
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(texture2D(u_Texture0, fc).r,
|
||||
texture2D(u_Texture1, fc).r,
|
||||
texture2D(u_Texture2, fc).r,
|
||||
1.0) * 0.9, 0.0, 1.0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else // CLIP ZOOM
|
||||
{
|
||||
// ZOOM CLIP
|
||||
if (fc.x < 0.0 || fc.x > 1.0) {
|
||||
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||
return;
|
||||
}
|
||||
fc.x *= u_effectiveWidth;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(texture2D(u_Texture0, fc).r,
|
||||
texture2D(u_Texture1, fc).r,
|
||||
texture2D(u_Texture2, fc).r,
|
||||
1.0), 0.0, 1.0);
|
||||
|
||||
}
|
||||
47
project/fm_viewer/fav/shaders/defish3.fsh
Normal file
47
project/fm_viewer/fav/shaders/defish3.fsh
Normal file
@@ -0,0 +1,47 @@
|
||||
uniform sampler2D u_Texture0;
|
||||
uniform sampler2D u_Texture1;
|
||||
uniform sampler2D u_Texture2;
|
||||
|
||||
// https://qiita.com/zinziroge/items/3676b4e0f7715fa60336
|
||||
// C:\Users\jeong\testing\theta_uvc_blender_mdk_ver.0.3.0
|
||||
// https://gist.github.com/dinhnhat0401/12910a5fee2e380051c55e5db752b279
|
||||
|
||||
|
||||
varying vec2 v_TexCoords0;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
|
||||
#define v_TexCoords1 v_TexCoords0
|
||||
#define v_TexCoords2 v_TexCoords0
|
||||
#define v_TexCoords3 v_TexCoords0
|
||||
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_colorMatrix;
|
||||
|
||||
uniform mat3 tune360;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fc = v_TexCoords0.st;
|
||||
vec2 src;
|
||||
|
||||
// Y 축은 상단이 1.0, 하단이 0.0
|
||||
// 원점 확인
|
||||
if(fc.x < 0.5) // left
|
||||
{
|
||||
// 좌측 이미지(0.5,1.0)-> 상단이미지(1.0,0.5)
|
||||
src = vec2(fc.x*2.0,0.5+(fc.y*0.5));
|
||||
}
|
||||
else // right
|
||||
{
|
||||
// 후측 이미지(0.5,1.0)-> 상단이미지(1.0,0.5)
|
||||
src = vec2((fc.x*2.0)-1.0,fc.y*0.5);
|
||||
}
|
||||
|
||||
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(texture2D(u_Texture0, src).r,
|
||||
texture2D(u_Texture1, src).r,
|
||||
texture2D(u_Texture2, src).r,
|
||||
1.0), 0.0, 1.0);
|
||||
}
|
||||
211
project/fm_viewer/fav/shaders/defish4.fsh
Normal file
211
project/fm_viewer/fav/shaders/defish4.fsh
Normal file
@@ -0,0 +1,211 @@
|
||||
uniform sampler2D u_Texture0;
|
||||
uniform sampler2D u_Texture1;
|
||||
uniform sampler2D u_Texture2;
|
||||
|
||||
varying vec2 v_TexCoords0;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
|
||||
#define v_TexCoords1 v_TexCoords0
|
||||
#define v_TexCoords2 v_TexCoords0
|
||||
#define v_TexCoords3 v_TexCoords0
|
||||
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_colorMatrix;
|
||||
|
||||
uniform mat3 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)
|
||||
{
|
||||
// -0.043600,-0.023700,-0.095750,
|
||||
// -0.040600,-0.025600,-0.185000,
|
||||
// 0.000000,0.000000,0.004600;
|
||||
//fobx = 180.0 * (1.0 + -0.05 *5.0);
|
||||
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[0][2]);
|
||||
}
|
||||
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[1][2]);
|
||||
}
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
215
project/fm_viewer/fav/shaders/defish5.fsh
Normal file
215
project/fm_viewer/fav/shaders/defish5.fsh
Normal file
@@ -0,0 +1,215 @@
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
265
project/fm_viewer/fav/shaders/defish_tb5000.fsh
Normal file
265
project/fm_viewer/fav/shaders/defish_tb5000.fsh
Normal file
@@ -0,0 +1,265 @@
|
||||
// precision highp float;
|
||||
uniform sampler2D u_Texture0;
|
||||
uniform sampler2D u_Texture1;
|
||||
uniform sampler2D u_Texture2;
|
||||
varying vec2 v_TexCoords0;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
|
||||
#define v_TexCoords1 v_TexCoords0
|
||||
#define v_TexCoords2 v_TexCoords0
|
||||
#define v_TexCoords3 v_TexCoords0
|
||||
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_colorMatrix;
|
||||
|
||||
uniform int u_mode;
|
||||
uniform float u_angle;
|
||||
uniform int u_flip;
|
||||
uniform float u_effectiveWidth;
|
||||
uniform float u_clipBound;
|
||||
uniform float u_screenWidth;
|
||||
uniform float u_screenHeight;
|
||||
uniform float u_realScreenWidth;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fc = v_TexCoords0.st;
|
||||
float PI = 3.141592;
|
||||
|
||||
float sw = u_screenWidth;
|
||||
float rsw = u_realScreenWidth;
|
||||
float sh = u_screenHeight;
|
||||
// 구분선 픽셀 크기
|
||||
float pw = (2.0 / u_realScreenWidth);// * u_effectiveWidth;
|
||||
float ph = (2.0 / u_screenHeight);
|
||||
|
||||
float tmin = 0.2;
|
||||
float tmax = 0.43;
|
||||
|
||||
const vec4 lineColor = vec4(0.796875,0.59765625,0.19921875,1.0);
|
||||
|
||||
// VR + PANORAMA
|
||||
if(u_mode == 2 || u_mode == 3)
|
||||
{
|
||||
float R = u_effectiveWidth / 2.0 * 0.96;//0.5;
|
||||
float Cfx = u_effectiveWidth / 2.0;
|
||||
float Cfy = 0.5;
|
||||
|
||||
float He = 1.0;
|
||||
float We = u_effectiveWidth;
|
||||
|
||||
float Xe = 1.0-fc.x; // flip h
|
||||
float Ye = 1.0-fc.y; // upside down
|
||||
|
||||
if(u_mode == 3){
|
||||
if(Ye > 0.62) {
|
||||
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||
return;
|
||||
}
|
||||
Ye = (Ye / 0.62);
|
||||
}
|
||||
|
||||
float r = Ye/He*R;
|
||||
float theta = Xe/We*2.0*PI;// - (u_angle * 3.0); // TOP_DOWN_2D_360
|
||||
float Xf = Cfx+r*sin(theta);
|
||||
float Yf = Cfy+r*cos(theta);
|
||||
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
else if(u_mode == 1) // PANORAMA 4CH
|
||||
{
|
||||
// 4분할 모드 (가로 라인 위치는 u_effectiveWidth 반영)
|
||||
float hw = u_effectiveWidth / 2.0;
|
||||
|
||||
if(abs(hw - fc.x) < pw || abs(0.5 - fc.y) < ph) {
|
||||
gl_FragColor = lineColor;//
|
||||
return;
|
||||
}
|
||||
|
||||
fc.y = 1.0 - fc.y;
|
||||
float R = u_effectiveWidth / 2.0 * 0.99;
|
||||
float Cfx = u_effectiveWidth / 2.0;
|
||||
float Cfy = 0.5;
|
||||
|
||||
float We = u_effectiveWidth;
|
||||
|
||||
float Xe = 1.0-fc.x; // flip h
|
||||
float Ye = 1.0-fc.y; // upside down
|
||||
|
||||
// 세로 분할 선
|
||||
if(fc.y < 0.5) // bottom AREA
|
||||
{
|
||||
/*
|
||||
Ye = 1.0-Ye;
|
||||
float r = (((Ye * (tmax - tmin)) / 0.5) + tmin); // (fmax - fmin) = 0.5
|
||||
float theta = Xe/We*PI+(PI/2.0); // 1/2
|
||||
theta += PI;
|
||||
float Xf = Cfx+r*sin(theta);
|
||||
float Yf = Cfy+r*cos(theta);
|
||||
fc = vec2(Xf,Yf);
|
||||
*/
|
||||
// Ye가 0.0일 때 안쪽(tmin), 0.5일 때 바깥쪽(tmax)이 되도록 매핑
|
||||
// 상하를 뒤집으려면 0.5 - fc.y를 사용하여 좌표 진행 방향을 반대로 바꿉니다.
|
||||
float Ye_flipped = 0.5 - fc.y;
|
||||
float r = (((Ye_flipped * (tmax - tmin)) / 0.5) + tmin);
|
||||
/*
|
||||
float theta = Xe/We*PI+(PI/2.0);
|
||||
theta += PI;
|
||||
float Xf = Cfx+r*sin(theta);
|
||||
float Yf = Cfy+r*cos(theta);
|
||||
fc = vec2(Xf,Yf);
|
||||
*/
|
||||
// 2. 좌우 반전 추가
|
||||
// Xe가 (1.0 - fc.x)이므로, 이를 다시 반전시키려면
|
||||
// We(효과 너비)에서 Xe를 뺀 값을 사용하거나 fc.x를 직접 활용합니다.
|
||||
float Xe_flipped = We - Xe;
|
||||
|
||||
// 3. 반전된 Xe_flipped를 사용하여 theta 계산
|
||||
float theta = Xe_flipped / We * PI + (PI / 2.0);
|
||||
theta += PI;
|
||||
|
||||
float Xf = Cfx + r * sin(theta);
|
||||
float Yf = Cfy + r * cos(theta);
|
||||
fc = vec2(Xf, Yf);
|
||||
}
|
||||
else // top AREA 180 ~ 360
|
||||
{
|
||||
Ye = 1.0-Ye-0.5;
|
||||
//float r = ((Ye*R) * 2.0) * clip_y + offset_y; //
|
||||
float r = (((Ye * (tmax - tmin)) / 0.5) + tmin); // (fmax - fmin) = 0.5
|
||||
float theta = Xe/We*PI+(PI/2.0); // 1/2
|
||||
float Xf = Cfx+r*sin(theta);
|
||||
float Yf = Cfy+r*cos(theta);
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
}
|
||||
else if(u_mode == 4) // 5CH 모드
|
||||
{
|
||||
float left_area_ratio = 0.5;
|
||||
float left_area_width = u_effectiveWidth * left_area_ratio;//min(sh / sw,0.5) * u_effectiveWidth;
|
||||
|
||||
if(abs(left_area_width - fc.x) < pw) {
|
||||
gl_FragColor = lineColor;
|
||||
return;
|
||||
}
|
||||
|
||||
// 5분할 모드
|
||||
float rx = fc.x;
|
||||
float ry = fc.y;
|
||||
|
||||
float R = u_effectiveWidth / 2.0 * 0.99;
|
||||
float Cfx = u_effectiveWidth / 2.0;
|
||||
float Cfy = 0.5;
|
||||
float We = u_effectiveWidth;
|
||||
|
||||
// 우측 (5채널)
|
||||
if (rx < left_area_width) {
|
||||
// 1:1 영역 은 보장됨
|
||||
float target_area = 0.4;
|
||||
float tx = rx * (1.0 / left_area_width) * target_area + ((1.0-target_area) * 0.5);
|
||||
float ty = ry * target_area + ((1.0-target_area) * 0.5);
|
||||
fc = vec2(tx,ty);
|
||||
} else {
|
||||
// 우측 4분할 (실제로는 2분할)
|
||||
// 나머지 영역 의
|
||||
// 좌우(abs(fc.x - h_center) < pw)
|
||||
// 상하( abs(fc.y - 0.5) < ph) 라인 그리기
|
||||
float h_center = (left_area_ratio + ((1.0 - left_area_ratio) * 0.5)) * u_effectiveWidth;
|
||||
if(abs(h_center - rx) < pw || abs(ry - 0.5) < ph) {
|
||||
gl_FragColor = lineColor;
|
||||
return;
|
||||
}
|
||||
// 4채널 모드와 동일
|
||||
float R = u_effectiveWidth / 2.0 * 0.99;
|
||||
float Cfx = u_effectiveWidth / 2.0;
|
||||
float Cfy = 0.5;
|
||||
|
||||
float We = u_effectiveWidth;
|
||||
|
||||
// ry 는 1.0 - left_area_width
|
||||
rx = (1.0 - (rx - left_area_width) / (1.0 - left_area_width));
|
||||
|
||||
if(ry > 0.5) // bottom AREA
|
||||
{
|
||||
|
||||
|
||||
/*
|
||||
ry = 1.0 - ((ry - 0.5) * 2.0); // ry 는 0.5~1.0 이므로 0.0~1.0으로 변환
|
||||
float r = ((((ry * R) * (tmax - tmin)) / 0.5) + tmin);
|
||||
|
||||
float theta = rx/We*PI+(PI/2.0); // 1/2
|
||||
theta += PI;
|
||||
float Xf = Cfx+r*sin(theta);
|
||||
float Yf = Cfy+r*cos(theta);
|
||||
fc = vec2(Xf,Yf);
|
||||
*/
|
||||
/*
|
||||
// --- 수정 부분 ---
|
||||
// 기존: ry = 1.0 - ((ry - 0.5) * 2.0); -> 중앙이 1.0, 하단끝이 0.0
|
||||
// 변경: 아래 식은 중앙(0.5)일 때 0.0, 하단끝(1.0)일 때 1.0이 됩니다.
|
||||
ry = (ry - 0.5) * 2.0;
|
||||
|
||||
float r = ((((ry * R) * (tmax - tmin)) / 0.5) + tmin);
|
||||
float theta = rx / We * PI + (PI / 2.0);
|
||||
theta += PI;
|
||||
float Xf = Cfx + r * sin(theta);
|
||||
float Yf = Cfy + r * cos(theta);
|
||||
fc = vec2(Xf, Yf);
|
||||
*/
|
||||
// 1. 상하 반전 처리 (기존 유지: 중앙 0.5일 때 r 최소, 바닥 1.0일 때 r 최대)
|
||||
ry = (ry - 0.5) * 2.0;
|
||||
float r = ((((ry * R) * (tmax - tmin)) / 0.5) + tmin);
|
||||
|
||||
// 2. 좌우 반전 추가
|
||||
// rx 값을 1.0에서 빼줌으로써 좌우를 뒤집습니다.
|
||||
float rx_flipped = 1.0 - rx;
|
||||
|
||||
// 3. 반전된 rx_flipped를 사용하여 theta 계산
|
||||
float theta = rx_flipped / We * PI + (PI / 2.0);
|
||||
theta += PI;
|
||||
|
||||
float Xf = Cfx + r * sin(theta);
|
||||
float Yf = Cfy + r * cos(theta);
|
||||
fc = vec2(Xf, Yf);
|
||||
}
|
||||
else // top AREA 180 ~ 360
|
||||
{
|
||||
ry = 1.0 - (ry * 2.0); // ry 는 0.0~0.5 이므로 0.0~1.0으로 변환
|
||||
float r = ((((ry * R) * (tmax - tmin)) / 0.5) + tmin);
|
||||
|
||||
float theta = rx/We*PI+(PI/2.0); // 1/2 = ANGLE
|
||||
float Xf = Cfx+r*sin(theta);
|
||||
float Yf = Cfy+r*cos(theta);
|
||||
fc = vec2(Xf,Yf);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else // FISH EYE
|
||||
{
|
||||
// ZOOM CLIP
|
||||
if (fc.x < 0.0 || fc.x > 1.0) {
|
||||
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||
return;
|
||||
}
|
||||
fc.x *= u_effectiveWidth;
|
||||
|
||||
// 1. 중앙 85%의 시작점 (버릴 영역의 크기: 15% / 2 = 7.5%)
|
||||
float START_UV = 0.075;
|
||||
|
||||
// 2. 텍스처의 85% 영역 크기
|
||||
float SCALE_RANGE = 1.0 - 2.0 * START_UV; // 0.85
|
||||
|
||||
// 3. 출력 UV (0.0~1.0)를 원본 텍스처의 중앙 85% 영역으로 매핑
|
||||
// New_UV = TexCoords * (0.85) + 0.075
|
||||
fc = fc * SCALE_RANGE + START_UV;
|
||||
}
|
||||
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(texture2D(u_Texture0, fc).r,
|
||||
texture2D(u_Texture1, fc).r,
|
||||
texture2D(u_Texture2, fc).r,
|
||||
1.0), 0.0, 1.0);
|
||||
|
||||
}
|
||||
56
project/fm_viewer/fav/shaders/dual.fsh
Normal file
56
project/fm_viewer/fav/shaders/dual.fsh
Normal file
@@ -0,0 +1,56 @@
|
||||
uniform sampler2D u_Texture0;
|
||||
uniform sampler2D u_Texture1;
|
||||
uniform sampler2D u_Texture2;
|
||||
|
||||
// https://gist.github.com/dinhnhat0401/12910a5fee2e380051c55e5db752b279
|
||||
|
||||
varying vec2 v_TexCoords0;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
|
||||
#define v_TexCoords1 v_TexCoords0
|
||||
#define v_TexCoords2 v_TexCoords0
|
||||
#define v_TexCoords3 v_TexCoords0
|
||||
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_colorMatrix;
|
||||
|
||||
// DEFISH
|
||||
float PI = 3.14159265358979;
|
||||
float _THETA_S_Y_SCALE = 640.0/720.0;//(1080.0 / 1920.0);
|
||||
|
||||
float radius = 1.0;
|
||||
//uniform vec4 uvOffset;
|
||||
//uniform vec2 radiusOffset;
|
||||
uniform mat4 tune360; // [0] = left [wzr], [1] right [yxr]
|
||||
uniform int resolution; // 0:FHD, 1:HD, 2:SD
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 st = v_TexCoords0.st;
|
||||
bool front = (tune360[0][0] > 0.5);
|
||||
|
||||
vec2 fc;
|
||||
if (front)
|
||||
{
|
||||
fc = vec2(st.x,min(st.y*0.5,0.499)); // 이거 왜하는거지???
|
||||
}
|
||||
else
|
||||
{
|
||||
fc = vec2(st.x,0.5001+st.y*0.5);
|
||||
}
|
||||
|
||||
// CLIP LEFT 1PX
|
||||
if(resolution == 2)
|
||||
{
|
||||
//fc.x = clamp(fc.x,0.0,0.90);
|
||||
//gl_FragColor = vec4(1.0,0.0,0.0,1.0);
|
||||
//return;
|
||||
}
|
||||
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(texture2D(u_Texture0, fc).r,
|
||||
texture2D(u_Texture1, fc).r,
|
||||
texture2D(u_Texture2, fc).r,
|
||||
1.0), 0.0, 1.0);
|
||||
}
|
||||
51
project/fm_viewer/fav/shaders/packed.f.glsl
Normal file
51
project/fm_viewer/fav/shaders/packed.f.glsl
Normal file
@@ -0,0 +1,51 @@
|
||||
/******************************************************************************
|
||||
QtAV: Multimedia framework based on Qt and FFmpeg
|
||||
Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>
|
||||
|
||||
* This file is part of QtAV
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
******************************************************************************/
|
||||
|
||||
uniform sampler2D u_Texture0;
|
||||
varying vec2 v_TexCoords0;
|
||||
uniform mat4 u_colorMatrix;
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_c;
|
||||
/***User header code***%userHeader%***/
|
||||
/***User sampling function here***%userSample%***/
|
||||
#ifndef USER_SAMPLER
|
||||
vec4 sample2d(sampler2D tex, vec2 pos, int plane)
|
||||
{
|
||||
return texture(tex, pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
vec4 c = sample2d(u_Texture0, v_TexCoords0, 0);
|
||||
c = u_c * c;
|
||||
#ifndef HAS_ALPHA
|
||||
c.a = 1.0; // before color mat transform!
|
||||
#endif //HAS_ALPHA
|
||||
#ifdef XYZ_GAMMA
|
||||
c.rgb = pow(c.rgb, vec3(2.6));
|
||||
#endif // XYZ_GAMMA
|
||||
c = u_colorMatrix * c;
|
||||
#ifdef XYZ_GAMMA
|
||||
c.rgb = pow(c.rgb, vec3(1.0/2.2));
|
||||
#endif //XYZ_GAMMA
|
||||
gl_FragColor = clamp(c, 0.0, 1.0) * u_opacity;
|
||||
/***User post processing here***%userPostProcess%***/
|
||||
}
|
||||
108
project/fm_viewer/fav/shaders/planar.f.glsl
Normal file
108
project/fm_viewer/fav/shaders/planar.f.glsl
Normal file
@@ -0,0 +1,108 @@
|
||||
/******************************************************************************
|
||||
QtAV: Multimedia framework based on Qt and FFmpeg
|
||||
Copyright (C) 2012-2016 Wang Bin <wbsecg1@gmail.com>
|
||||
|
||||
* This file is part of QtAV
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
******************************************************************************/
|
||||
// u_TextureN: yuv. use array?
|
||||
uniform sampler2D u_Texture0;
|
||||
uniform sampler2D u_Texture1;
|
||||
uniform sampler2D u_Texture2;
|
||||
#ifdef HAS_ALPHA
|
||||
uniform sampler2D u_Texture3;
|
||||
#endif //HAS_ALPHA
|
||||
varying vec2 v_TexCoords0;
|
||||
#ifdef MULTI_COORD
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
#ifdef HAS_ALPHA
|
||||
varying vec2 v_TexCoords3;
|
||||
#endif
|
||||
#else
|
||||
#define v_TexCoords1 v_TexCoords0
|
||||
#define v_TexCoords2 v_TexCoords0
|
||||
#define v_TexCoords3 v_TexCoords0
|
||||
#endif //MULTI_COORD
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_colorMatrix;
|
||||
#ifdef CHANNEL16_TO8
|
||||
uniform vec2 u_to8;
|
||||
#endif
|
||||
/***User header code***%userHeader%***/
|
||||
// matrixCompMult for convolution
|
||||
/***User sampling function here***%userSample%***/
|
||||
#ifndef USER_SAMPLER
|
||||
vec4 sample2d(sampler2D tex, vec2 pos, int plane)
|
||||
{
|
||||
return texture(tex, pos);
|
||||
}
|
||||
#endif
|
||||
|
||||
// 10, 16bit: http://msdn.microsoft.com/en-us/library/windows/desktop/bb970578%28v=vs.85%29.aspx
|
||||
void main()
|
||||
{
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(
|
||||
#ifdef CHANNEL16_TO8
|
||||
#ifdef USE_RG
|
||||
dot(sample2d(u_Texture0, v_TexCoords0, 0).rg, u_to8),
|
||||
dot(sample2d(u_Texture1, v_TexCoords1, 1).rg, u_to8),
|
||||
dot(sample2d(u_Texture2, v_TexCoords2, 2).rg, u_to8),
|
||||
#else
|
||||
dot(sample2d(u_Texture0, v_TexCoords0, 0).ra, u_to8),
|
||||
dot(sample2d(u_Texture1, v_TexCoords1, 1).ra, u_to8),
|
||||
dot(sample2d(u_Texture2, v_TexCoords2, 2).ra, u_to8),
|
||||
#endif //USE_RG
|
||||
#else
|
||||
#ifdef USE_RG
|
||||
sample2d(u_Texture0, v_TexCoords0, 0).r,
|
||||
sample2d(u_Texture1, v_TexCoords1, 1).r,
|
||||
#ifdef IS_BIPLANE
|
||||
sample2d(u_Texture2, v_TexCoords2, 2).g,
|
||||
#else
|
||||
sample2d(u_Texture2, v_TexCoords2, 2).r,
|
||||
#endif //IS_BIPLANE
|
||||
#else
|
||||
// use r, g, a to work for both yv12 and nv12. idea from xbmc
|
||||
sample2d(u_Texture0, v_TexCoords0, 0).r,
|
||||
sample2d(u_Texture1, v_TexCoords1, 1).g,
|
||||
sample2d(u_Texture2, v_TexCoords2, 2).a,
|
||||
#endif //USE_RG
|
||||
#endif //CHANNEL16_TO8
|
||||
1.0
|
||||
)
|
||||
, 0.0, 1.0) * u_opacity;
|
||||
#ifdef HAS_ALPHA
|
||||
float a =
|
||||
#ifdef CHANNEL16_TO8
|
||||
#ifdef USE_RG
|
||||
dot(sample2d(u_Texture3, v_TexCoords3, 3).rg, u_to8);
|
||||
#else
|
||||
dot(sample2d(u_Texture3, v_TexCoords3, 3).ra, u_to8);
|
||||
#endif
|
||||
#else
|
||||
#ifdef USE_RG
|
||||
sample2d(u_Texture3, v_TexCoords3, 3).r;
|
||||
#else
|
||||
sample2d(u_Texture3, v_TexCoords3, 3).a;
|
||||
#endif
|
||||
#endif
|
||||
gl_FragColor.rgb = gl_FragColor.rgb*a;
|
||||
gl_FragColor.a = a;
|
||||
#endif //HAS_ALPHA
|
||||
/***User post processing here***%userPostProcess%***/
|
||||
}
|
||||
15
project/fm_viewer/fav/shaders/shaders.qrc
Normal file
15
project/fm_viewer/fav/shaders/shaders.qrc
Normal file
@@ -0,0 +1,15 @@
|
||||
<RCC>
|
||||
<qresource prefix="/shaders">
|
||||
<file>planar.f.glsl</file>
|
||||
<file>packed.f.glsl</file>
|
||||
<file>video.vert</file>
|
||||
<file>defish2.fsh</file>
|
||||
<file>dual.fsh</file>
|
||||
<file>defish3.fsh</file>
|
||||
<file>defish4.fsh</file>
|
||||
<file>defish5.fsh</file>
|
||||
<file>defish2.vsh</file>
|
||||
<file>defish2d.fsh</file>
|
||||
<file>wide.fsh</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
47
project/fm_viewer/fav/shaders/video.vert
Normal file
47
project/fm_viewer/fav/shaders/video.vert
Normal file
@@ -0,0 +1,47 @@
|
||||
/******************************************************************************
|
||||
QtAV: Multimedia framework based on Qt and FFmpeg
|
||||
Copyright (C) 2015 Wang Bin <wbsecg1@gmail.com>
|
||||
|
||||
* This file is part of QtAV
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
******************************************************************************/
|
||||
attribute vec4 a_Position;
|
||||
attribute vec2 a_TexCoords0;
|
||||
uniform mat4 u_Matrix;
|
||||
varying vec2 v_TexCoords0;
|
||||
#ifdef MULTI_COORD
|
||||
attribute vec2 a_TexCoords1;
|
||||
attribute vec2 a_TexCoords2;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
#ifdef HAS_ALPHA
|
||||
attribute vec2 a_TexCoords3;
|
||||
varying vec2 v_TexCoords3;
|
||||
#endif
|
||||
#endif //MULTI_COORD
|
||||
/***User header code***%userHeader%***/
|
||||
|
||||
void main() {
|
||||
gl_Position = u_Matrix * a_Position;
|
||||
v_TexCoords0 = a_TexCoords0;
|
||||
#ifdef MULTI_COORD
|
||||
v_TexCoords1 = a_TexCoords1;
|
||||
v_TexCoords2 = a_TexCoords2;
|
||||
#ifdef HAS_ALPHA
|
||||
v_TexCoords3 = a_TexCoords3;
|
||||
#endif
|
||||
#endif //MULTI_COORD
|
||||
}
|
||||
97
project/fm_viewer/fav/shaders/wide.fsh
Normal file
97
project/fm_viewer/fav/shaders/wide.fsh
Normal file
@@ -0,0 +1,97 @@
|
||||
uniform sampler2D u_Texture0;
|
||||
uniform sampler2D u_Texture1;
|
||||
uniform sampler2D u_Texture2;
|
||||
|
||||
// https://github.com/tokoik/fisheye ...
|
||||
// https://stackoverflow.com/questions/39352533/android-opengl-es-textured-half-sphere ???
|
||||
varying vec2 v_TexCoords0;
|
||||
varying vec2 v_TexCoords1;
|
||||
varying vec2 v_TexCoords2;
|
||||
|
||||
#define v_TexCoords1 v_TexCoords0
|
||||
#define v_TexCoords2 v_TexCoords0
|
||||
#define v_TexCoords3 v_TexCoords0
|
||||
|
||||
uniform float u_opacity;
|
||||
uniform mat4 u_colorMatrix;
|
||||
|
||||
uniform int u_mode; // 0: NORMAL, 1:WIDE
|
||||
uniform float u_aspect; // 스크린 AR
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec2 fc = v_TexCoords0.st;
|
||||
float PI = 3.14159265359;
|
||||
|
||||
if (u_mode == 1) {
|
||||
// Pin Cushion Dewarp
|
||||
// --- 파라미터 조절 ---
|
||||
// STRENGTH_X: 좌우(가로) 방향으로 펴는 강도
|
||||
float STRENGTH_X_TOP = 0.27;
|
||||
float STRENGTH_X_BOTTOM = 0.47;
|
||||
|
||||
// STRENGTH_Y: 상하(세로) 방향으로 펴는 강도
|
||||
float STRENGTH_Y_TOP = 0.85;
|
||||
float STRENGTH_Y_BOTTOM = 0.5;
|
||||
|
||||
// ZOOM: 전체 확대/축소 비율
|
||||
float ZOOM = 1.08;
|
||||
|
||||
// 2. 중심을 중앙으로 이동 [-0.5, 0.5]
|
||||
vec2 centeredUV = fc - 0.5;
|
||||
|
||||
// 3. 화면 비율(Aspect Ratio) 보정
|
||||
// 가로가 긴 화면에서 원이 타원이 되지 않도록 X좌표를 보정합니다.
|
||||
centeredUV.x *= u_aspect;
|
||||
|
||||
// 4. 중심으로부터의 거리(반지름) 제곱 계산
|
||||
float r2 = dot(centeredUV, centeredUV);
|
||||
|
||||
// 5. Y축 강도 보간 계수 (t) 계산
|
||||
// uv.y는 [0.0 (바닥) ~ 1.0 (천장)] 범위를 가지며, 이를 보간 계수로 사용합니다.
|
||||
float t = 1.0- fc.y;
|
||||
|
||||
// 6. X축 강도 선형 보간
|
||||
// 하단(t=0.0)에서 STRENGTH_X_BOTTOM, 상단(t=1.0)에서 STRENGTH_X_TOP
|
||||
float current_STRENGTH_X = mix(STRENGTH_X_BOTTOM, STRENGTH_X_TOP, t);
|
||||
|
||||
// 7. Y축 강도 선형 보간
|
||||
// 하단(t=0.0)에서 STRENGTH_Y_BOTTOM, 상단(t=1.0)에서 STRENGTH_Y_TOP
|
||||
float current_STRENGTH_Y = mix(STRENGTH_Y_BOTTOM, STRENGTH_Y_TOP, t);
|
||||
|
||||
// 5. 왜곡 보정 (X, Y 개별 적용)
|
||||
// r2(중심에서의 거리)에 따라 보정하되, 축별로 다른 강도를 곱합니다.
|
||||
float factorX = 1.0 / (1.0 + current_STRENGTH_X * r2);
|
||||
float factorY = 1.0 / (1.0 + current_STRENGTH_Y * r2);
|
||||
|
||||
// 6. 보정된 좌표 계산 (ZOOM 적용 포함)
|
||||
// X축에는 factorX, Y축에는 factorY를 각각 곱해줍니다.
|
||||
vec2 distortedUV = centeredUV * vec2(factorX, factorY) * ZOOM;
|
||||
|
||||
// 7. 화면 비율 복원
|
||||
distortedUV.x /= u_aspect;
|
||||
|
||||
// 8. 좌표 범위를 다시 [0, 1]로 복귀
|
||||
fc = distortedUV + 0.5;
|
||||
|
||||
if(fc.x < 0.0 || fc.y < 0.0 || fc.x > 1.0 || fc.y > 1.0) {
|
||||
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else // 일반모드
|
||||
{
|
||||
// ZOOM CLIP
|
||||
if (fc.x < 0.0 || fc.x > 1.0) {
|
||||
gl_FragColor = vec4(0.0,0.0,0.0,1.0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
gl_FragColor = clamp(u_colorMatrix
|
||||
* vec4(texture2D(u_Texture0, fc).r,
|
||||
texture2D(u_Texture1, fc).r,
|
||||
texture2D(u_Texture2, fc).r,
|
||||
1.0), 0.0, 1.0);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user