git-svn-id: svn://db.shs.com.ru/libs@30 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2015-06-25 08:28:11 +00:00
parent ff2939ca76
commit 8b5dca853a
27 changed files with 1062 additions and 0 deletions

View File

@@ -39,6 +39,10 @@ class GLPrimitiveLine: public GLObjectBase
public:
GLPrimitiveLine(QVector3D p0_ = QVector3D(), QVector3D p1_ = QVector3D()) {p0 = p0_; p1 = p1_;}
virtual void draw(bool simplest = false);
QVector3D point0() const {return p0;}
QVector3D point1() const {return p1;}
void setPoint0(const QVector3D & p) {p0 = p;}
void setPoint1(const QVector3D & p) {p1 = p;}
private:
QVector3D p0, p1;
};

230
qglview/shaders/FXAA.frag Normal file
View File

@@ -0,0 +1,230 @@
#version 130
in vec4 posPos;
uniform sampler2D tex0; // 0
//uniform float vx_offset;
uniform vec2 dt;
uniform float FXAA_SPAN_MAX = 8.;
uniform float FXAA_REDUCE_MUL = 1. / 8.;
#define FxaaInt2 ivec2
//#define vec2 vec2
vec3 FxaaPixelShader(vec4 posPos, // Output of FxaaVertexShader interpolated across screen.
sampler2D tex, // Input texture.
vec2 rcpFrame) { // Constant {1.0/frameWidth, 1.0/frameHeight}.
/*---------------------------------------------------------*/
// #define FXAA_REDUCE_MIN (1. / 128.)
#define FXAA_REDUCE_MIN (1. / 128.)
//#define FXAA_REDUCE_MUL (1.0/8.0)
//#define FXAA_SPAN_MAX 8.0
/*---------------------------------------------------------*/
vec3 rgbNW = texture2D(tex, posPos.zw).xyz;
vec3 rgbNE = textureOffset(tex, posPos.zw, ivec2(1, 0)).xyz;
vec3 rgbSW = textureOffset(tex, posPos.zw, ivec2(0, 1)).xyz;
vec3 rgbSE = textureOffset(tex, posPos.zw, ivec2(1, 1)).xyz;
vec3 rgbM = texture2D(tex, posPos.xy).xyz;
/*---------------------------------------------------------*/
vec3 luma = vec3(0.299, 0.587, 0.114);
float lumaNW = dot(rgbNW, luma);
float lumaNE = dot(rgbNE, luma);
float lumaSW = dot(rgbSW, luma);
float lumaSE = dot(rgbSE, luma);
float lumaM = dot(rgbM, luma);
/*---------------------------------------------------------*/
float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE)));
float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE)));
/*---------------------------------------------------------*/
vec2 dir;
dir.x = -((lumaNW + lumaNE) - (lumaSW + lumaSE));
dir.y = ((lumaNW + lumaSW) - (lumaNE + lumaSE));
/*---------------------------------------------------------*/
float dirReduce = max(
(lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL),
FXAA_REDUCE_MIN);
float rcpDirMin = 1. / (min(abs(dir.x), abs(dir.y)) + dirReduce);
dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX),
max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX),
dir * rcpDirMin)) * rcpFrame.xy;
/*--------------------------------------------------------*/
vec3 rgbA = (1. / 2.) * (
texture2D(tex, posPos.xy + dir * (1. / 3. - 0.5)).xyz +
texture2D(tex, posPos.xy + dir * (2. / 3. - 0.5)).xyz);
vec3 rgbB = rgbA * (1. / 2.) + (1. / 4.) * (
texture2D(tex, posPos.xy + dir * (0. / 3. - 0.5)).xyz +
texture2D(tex, posPos.xy + dir * (3. / 3. - 0.5)).xyz);
float lumaB = dot(rgbB, luma);
if ((lumaB < lumaMin) || (lumaB > lumaMax)) return rgbA;
return rgbB;
}
vec3 Fxaa3PixelShader (
// {xy} = center of pixel
vec4 pos,
// {xyzw} = not used on FXAA3 Quality
//vec4 posPos,
// {rgb_} = color in linear or perceptual color space
// {__a} = luma in perceptual color space (not linear)
sampler2D tex,
// This must be from a constant/uniform.
// {x_} = 1.0/screenWidthInPixels
// {_y} = 1.0/screenHeightInPixels
vec2 rcpFrame
// {xyzw} = not used on FXAA3 Quality
//vec4 rcpFrameOpt
) {
/*--------------------------------------------------------------------------*/
//#if (FXAA_GATHER4_ALPHA == 1)
/*vec4 luma4A = FxaaTexOffAlpha4(tex, pos.xy, FxaaInt2(-1, -1), rcpFrame.xy);
#if (FXAA_DISCARD == 0)
vec4 rgbyM = texture2D(tex, pos.xy);
#endif
vec4 luma4B = FxaaTexAlpha4(tex, pos.xy, rcpFrame.xy);
float lumaNE = textureOffset(tex, pos.xy, ivec(1, -1)).w;
float lumaSW = textureOffset(tex, pos.xy, ivec(-1, 1)).w;
float lumaNW = luma4A.w;
float lumaN = luma4A.z;
float lumaW = luma4A.x;
float lumaM = luma4A.y;
float lumaE = luma4B.z;
float lumaS = luma4B.x;
float lumaSE = luma4B.y;*/
//#else
vec3 luma = vec3(0.299, 0.587, 0.114);
float lumaN = dot(textureLodOffset(tex, pos.xy, 0., ivec2(0, -1)).rgb, luma);
float lumaW = dot(textureLodOffset(tex, pos.xy, 0., ivec2(-1, 0)).rgb, luma);
vec4 rgbyM = texture2D(tex, pos.xy);
float lumaE = dot(textureLodOffset(tex, pos.xy, 0., ivec2( 1, 0)).rgb, luma);
float lumaS = dot(textureLodOffset(tex, pos.xy, 0., ivec2( 0, 1)).rgb, luma);
float lumaM = dot(rgbyM.rgb, luma);
//#endif
/*--------------------------------------------------------------------------*/
float rangeMin = min(lumaM, min(min(lumaN, lumaW), min(lumaS, lumaE)));
float rangeMax = max(lumaM, max(max(lumaN, lumaW), max(lumaS, lumaE)));
float range = rangeMax - rangeMin;
//return vec4(range);
/*--------------------------------------------------------------------------*/
#define FXAA_QUALITY_EDGE_THRESHOLD_MIN (1.0/12.0)
#define FXAA_QUALITY_EDGE_THRESHOLD (1.0/6.0)
if(range < max(FXAA_QUALITY_EDGE_THRESHOLD_MIN, rangeMax * FXAA_QUALITY_EDGE_THRESHOLD))
/*#if (FXAA_DISCARD == 1)
FxaaDiscard;
#else*/
return rgbyM.rgb;
//return vec3(0);
//#endif
/*--------------------------------------------------------------------------*/
//#if (FXAA_GATHER4_ALPHA == 0)
float lumaNW = dot(textureLodOffset(tex, pos.xy, 0., ivec2(-1,-1)).rgb, luma);
float lumaNE = dot(textureLodOffset(tex, pos.xy, 0., ivec2( 1,-1)).rgb, luma);
float lumaSW = dot(textureLodOffset(tex, pos.xy, 0., ivec2(-1, 1)).rgb, luma);
float lumaSE = dot(textureLodOffset(tex, pos.xy, 0., ivec2( 1, 1)).rgb, luma);
//#endif
/*--------------------------------------------------------------------------*/
#define FXAA_QUALITY_SUBPIX_CAP (3.0/4.0)
//#define FXAA_QUALITY_SUBPIX_CAP 0
#define FXAA_QUALITY_SUBPIX_TRIM (1.0/4.0)
#define FXAA_QUALITY_SUBPIX_TRIM_SCALE (1.0/(1.0 - FXAA_QUALITY_SUBPIX_TRIM))
/*--------------------------------------------------------------------------*/
float lumaL = (lumaN + lumaW + lumaE + lumaS) * 0.25;
float rangeL = abs(lumaL - lumaM);
float blendL = clamp((rangeL / range) - FXAA_QUALITY_SUBPIX_TRIM, 0., 1.) * FXAA_QUALITY_SUBPIX_TRIM_SCALE;
blendL = min(FXAA_QUALITY_SUBPIX_CAP, blendL);
/*--------------------------------------------------------------------------*/
float edgeVert =
abs(lumaNW + (-2.0 * lumaN) + lumaNE) +
10.0 * abs(lumaW + (-2.0 * lumaM) + lumaE ) +
abs(lumaSW + (-2.0 * lumaS) + lumaSE);
float edgeHorz =
abs(lumaNW + (-2.0 * lumaW) + lumaSW) +
10.0 * abs(lumaN + (-2.0 * lumaM) + lumaS ) +
abs(lumaNE + (-2.0 * lumaE) + lumaSE);
//return vec3(edgeHorz);
//float edgeVert = abs(lumaS - lumaN);
//float edgeHorz = abs(lumaE - lumaW);
bool horzSpan = edgeHorz >= edgeVert;
/*--------------------------------------------------------------------------*/
float lengthSign = horzSpan ? -rcpFrame.y : -rcpFrame.x;
//if (edgeHorz == edgeVert) ;//lengthSign = 0.;
if(!horzSpan) {
lumaN = lumaW;
lumaS = lumaE;
}
float gradientN = abs(lumaN - lumaM);
float gradientS = abs(lumaS - lumaM);
lumaN = (lumaN + lumaM) * 0.5;
lumaS = (lumaS + lumaM) * 0.5;
/*--------------------------------------------------------------------------*/
bool pairN = gradientN >= gradientS;
if(!pairN) {
lumaN = lumaS;
gradientN = gradientS;
lengthSign = -lengthSign;
}
vec2 posN;
posN = pos.xy + (horzSpan ? vec2(0.0, lengthSign * 0.5) : vec2(lengthSign * 0.5, 0.0));
//posN.x = pos.x + (horzSpan ? 0.0 : lengthSign * 0.5);
//posN.y = pos.y + (horzSpan ? lengthSign * 0.5 : 0.0);
/*--------------------------------------------------------------------------*/
#define FXAA_SEARCH_STEPS 8
#define FXAA_SEARCH_THRESHOLD (1.0/8.0)
/*--------------------------------------------------------------------------*/
gradientN *= FXAA_SEARCH_THRESHOLD;
/*--------------------------------------------------------------------------*/
vec2 posP = posN;
vec2 offNP = horzSpan ? vec2(rcpFrame.x, 0.0) : vec2(0.0, rcpFrame.y);
float lumaEndN = 0.;
float lumaEndP = 0.;
bool doneN = false;
bool doneP = false;
posN += offNP * (-1.5);
posP += offNP * ( 1.5);
for(int i = 0; i < FXAA_SEARCH_STEPS; i++) {
lumaEndN = dot(texture2DLod(tex, posN.xy, 0.).rgb, luma);
lumaEndP = dot(texture2DLod(tex, posP.xy, 0.).rgb, luma);
bool doneN2 = abs(lumaEndN - lumaN) >= gradientN;
bool doneP2 = abs(lumaEndP - lumaN) >= gradientN;
if(doneN2 && !doneN) posN += offNP;
if(doneP2 && !doneP) posP -= offNP;
if(doneN2 && doneP2) break;
doneN = doneN2;
doneP = doneP2;
if(!doneN) posN -= offNP * 2.0;
if(!doneP) posP += offNP * 2.0;
}
/*--------------------------------------------------------------------------*/
float dstN = horzSpan ? pos.x - posN.x : pos.y - posN.y;
float dstP = horzSpan ? posP.x - pos.x : posP.y - pos.y;
/*--------------------------------------------------------------------------*/
bool directionN = dstN < dstP;
lumaEndN = directionN ? lumaEndN : lumaEndP;
/*--------------------------------------------------------------------------*/
if(((lumaM - lumaN) < 0.0) == ((lumaEndN - lumaN) < 0.0))
lengthSign = 0.0;
/*--------------------------------------------------------------------------*/
float spanLength = (dstP + dstN);
dstN = directionN ? dstN : dstP;
float subPixelOffset = 0.5 + (dstN * (-1.0/spanLength));
subPixelOffset += blendL * (1.0/8.0);
subPixelOffset *= lengthSign;
vec3 rgbF = texture2DLod(tex, pos.xy + (horzSpan ? vec2(0., subPixelOffset) : vec2(subPixelOffset, 0.)), 0.).xyz;
/*--------------------------------------------------------------------------*/
/*#if (FXAA_LINEAR == 1)
lumaL *= lumaL;
#endif*/
float lumaF = dot(rgbF, vec3(0.299, 0.587, 0.114)) + (1.0/(65536.0*256.0));
float lumaB = mix(lumaF, lumaL, blendL);
float scale = min(4.0, lumaB/lumaF);
rgbF *= scale;
return vec3(rgbF);//, lumaM.rgb);
//, lumaM.rgb);
}
void main() {
gl_FragColor.rgb = Fxaa3PixelShader(posPos, tex0, dt);
}

13
qglview/shaders/FXAA.vert Normal file
View File

@@ -0,0 +1,13 @@
#version 130
out vec4 posPos;
uniform float FXAA_SUBPIX_SHIFT = 1. / 4.;
uniform vec2 dt;
void main(void) {
posPos.xy = gl_MultiTexCoord0.xy;
posPos.zw = gl_MultiTexCoord0.xy - (dt * (0.5 + FXAA_SUBPIX_SHIFT));
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}

View File

@@ -0,0 +1,8 @@
#version 120
uniform sampler2D t0;
uniform float clum;
void main(void) {
gl_FragColor = max((texture2D(t0, gl_TexCoord[0].xy) / clum - 0.8) * 5., vec4(0.));
}

View File

@@ -0,0 +1,30 @@
#version 130
uniform sampler2D t0;
uniform vec2 vsize;
void main(void) {
vec2 tc = gl_TexCoord[0].xy, dt = 2. / vsize, dt2 = dt + dt;
gl_FragColor = (texture2D(t0, tc) * 3. +
textureOffset(t0, tc, ivec2(1, 0)) * 2. +
textureOffset(t0, tc, ivec2(0, 1)) * 2. +
textureOffset(t0, tc, ivec2(-1, 0)) * 2. +
textureOffset(t0, tc, ivec2(0, -1)) * 2. +
textureOffset(t0, tc, ivec2(1, 1)) * 1.5 +
textureOffset(t0, tc, ivec2(1, -1)) * 1.5 +
textureOffset(t0, tc, ivec2(-1, -1)) * 1.5 +
textureOffset(t0, tc, ivec2(-1, 1)) * 1.5 +
textureOffset(t0, tc, ivec2(2, 0)) +
textureOffset(t0, tc, ivec2(0, 2)) +
textureOffset(t0, tc, ivec2(-2, 0)) +
textureOffset(t0, tc, ivec2(0, -2)) +
textureOffset(t0, tc, ivec2(2, 1)) +
textureOffset(t0, tc, ivec2(2, -1)) +
textureOffset(t0, tc, ivec2(-2, -1)) +
textureOffset(t0, tc, ivec2(-2, 1)) +
textureOffset(t0, tc, ivec2(1, 2)) +
textureOffset(t0, tc, ivec2(1, -2)) +
textureOffset(t0, tc, ivec2(-1, -2)) +
textureOffset(t0, tc, ivec2(-1, 2))) / 29.;
//gl_FragColor = texture2D(t0, tc);
}

View File

@@ -0,0 +1,52 @@
#version 130
in vec3 src_normal, normal, et;
in vec4 pos, col;
in float fogCoord;
uniform int light_model;
uniform sampler2D t0, t1, t2, t3;
uniform float bump_scale, height_scale;
uniform bool acc_fog, has_diffuse, has_bump, has_height;
uniform vec2 dt;
const vec3 luma = vec3(0.299, 0.587, 0.114);
void main(void) {
vec4 dc = col;
vec2 tc = gl_TexCoord[0].xy;
float hei = 0.;
if (has_height) hei = dot(texture2D(t2, gl_TexCoord[0].xy).rgb, luma) * height_scale;
if (acc_fog) dc.xyz = mix(dc.rgb, gl_Fog.color.rgb, fogCoord);
vec3 n;
if (has_bump) n = normalize(normal - (texture2D(t1, gl_TexCoord[0].xy).rgb - vec3(0.5, 0.5, 1.)) * bump_scale);
else n = normalize(normal);
if (has_diffuse) {
/*vec2 dpm = normalize(gl_FragCoord.xy * dt * 2. - vec2(1., 1.)), ntc;
ntc = gl_FragCoord.xy * dt * 2. - vec2(1., 1.) + dpm * hei;
dpm = gl_ModelViewProjectionMatrixInverse
dpm = dpm * gl_ModelViewProjectionMatrixInverse;
dpm += */
tc += 1-et.xy * hei/10;// / et.z;
dc *= texture2D(t0, tc);
}
gl_FragData[0] = vec4(dc.rgb, pos.w);
gl_FragData[1] = vec4(n.xyz / 2. + vec3(0.5), gl_FrontMaterial.shininess);
gl_FragData[2] = vec4(gl_FrontMaterial.specular.rgb, hei);
//gl_FragData[0] = vec4(et.xyz, pos.w);
//gl_FragDepth = gl_FragCoord.z - clamp(hei / pos.z / pos.z / (abs(n.z) + 1), -0.01, 0.01);
/*vec4 dp = pos;
dp.x = floor(dp.w / 255.) / 255.;
dp.w -= dp.x * 65025;
dp.y = floor(dp.w) / 255.;
dp.w -= dp.y * 255.;
dp.z = fract(dp.w);*/
//dp.x = dp.w;
//dp.w = (gl_FrontMaterial.specular.r + gl_FrontMaterial.specular.g + gl_FrontMaterial.specular.b) / 3. / 25.5;
//gl_FragData[2] = dp;
//gl_FragData[3] = vec4(light_model / 255., 0, 0, 0);
}

View File

@@ -0,0 +1,14 @@
#version 130
layout(triangles, invocations = 1) in;
in vec3 normal[];
out vec3 tangent[];
void main() {
for (int i = 0; i < gl_in.length(); i++ ) {
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}

View File

@@ -0,0 +1,42 @@
#version 130
out vec3 src_normal, normal, et;
out vec4 pos, col;
out float fogCoord, fs_gid;
uniform bool acc_fog;
uniform vec2 dt;
uniform vec3 eye;
void main(void) {
normal = (gl_NormalMatrix * gl_Normal);
pos.xyz = vec3(gl_ModelViewMatrix * gl_Vertex);
col = gl_Color;
if (acc_fog) {
fogCoord = (gl_Fog.end - length(pos.xyz) * 0.85) / (gl_Fog.end - gl_Fog.start);
fogCoord = 1. - clamp(fogCoord, 0., 1.);
}
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
gl_Position = ftransform();
src_normal = normalize(/*gl_NormalMatrix * */vec3(pos.xy * dt * 2., 0));
//pos = gl_Position;
vec3 v = normalize(-pos.xyz); // vector to the eye
/*vec3 t = gl_NormalMatrix * vec3(1., 0., 0.);
vec3 b = gl_NormalMatrix * vec3(0., 1., 0.);
et = vec3(dot(v, t), dot(v, b), dot(v, normal));*/
vec3 t = normalize(gl_NormalMatrix * vec3(gl_MultiTexCoord0.yx, 1));
vec3 b = cross(normal, t);
mat3 tbnMatrix = mat3(t.x, b.x, normal.x,
t.y, b.y, normal.y,
t.z, b.z, normal.z);
et = tbnMatrix * v;
pos.w = gl_Position.w;
}

View File

@@ -0,0 +1,94 @@
#version 130
//#extension GL_EXT_gpu_shader4 : enable
uniform vec3 ambient;
uniform sampler2D t0, t1, t2, tb;
uniform int gid, lightsCount;
uniform bool firstPass;
uniform vec2 dt;
uniform vec4 back_color;
//uniform vec3 eye;
//uniform vec4 lpos[8];
uniform mat4 mat;
//uniform float zNear, zFar;
float light_diffuse(int model, vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {return max(0., dot(l, n));}
float light_specular(int model, vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {return max(0., pow(dot(n, h), shininess));}
vec4 pos, lpos;
vec3 li, si, ldir, halfV;
float sh, dist, NdotL, spot, ldist;
void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
lpos = gl_LightSource[index].position;
ldir = lpos.xyz - (pos.xyz * lpos.w);
ldist = length(ldir);
ldir = normalize(ldir);
NdotL = max(dot(n, ldir), 0.);
spot = step(0., NdotL);
if (NdotL > 0.) {
if (gl_LightSource[index].spotCutoff < 180.) {
spot = max(dot(-ldir, gl_LightSource[index].spotDirection.xyz), 0.);
spot *= step(gl_LightSource[index].spotCosCutoff, spot);
spot = pow(spot, (gl_LightSource[index].spotExponent + 0.001));
}
halfV = normalize(ldir + v);
//i += gl_LightSource[i].diffuse.rgb * NdotL;
//si += gl_LightSource[i].specular.rgb * pow(max(dot(n, halfV), 0.), sh);
spot /= (gl_LightSource[index].constantAttenuation + ldist * (gl_LightSource[index].linearAttenuation + ldist * gl_LightSource[index].quadraticAttenuation));
li += spot * gl_LightSource[index].diffuse.rgb * light_diffuse(0, ldir, n, halfV, v, sh);
si += spot * gl_LightSource[index].specular.rgb * v2.rgb * light_specular(0, ldir, n, halfV, v, sh);
}
//li = vec3(gl_LightSource[index].spotExponent);
//si = vec3(0);
}
void main(void) {
//if (d == 1.) discard;
vec4 v0 = texture2D(t0, gl_TexCoord[0].xy);
if (v0.w == 0.) {
gl_FragColor = back_color;
return;
}
vec4 v1 = texture2D(t1, gl_TexCoord[0].xy), v2 = texture2D(t2, gl_TexCoord[0].xy);//, v3 = texture2D(t3, gl_TexCoord[0].xy);
vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
vec3 dc = v0.rgb, n = v1.xyz * 2. - vec3(1.);
float height = v2.w;
li = gl_LightModel.ambient.rgb;
si = vec3(0.);
pos = vec4(sp, 0, 1.) * mat;
pos *= v0.w;
pos.rgb += n * height;
vec3 v = normalize(-pos.xyz);
sh = v1.w;
//int light_model = int(v3.r * 255. + 0.5);
//li = ambient;
if (lightsCount > 0) {
calcLight(0, n, v, v2);
if (lightsCount > 1) {
calcLight(1, n, v, v2);
if (lightsCount > 2) {
calcLight(2, n, v, v2);
if (lightsCount > 3) {
calcLight(3, n, v, v2);
if (lightsCount > 4) {
calcLight(4, n, v, v2);
if (lightsCount > 5) {
calcLight(5, n, v, v2);
if (lightsCount > 6) {
calcLight(6, n, v, v2);
if (lightsCount > 7) {
calcLight(7, n, v, v2);
}
}
}
}
}
}
}
}
gl_FragColor.rgb = li * dc + si + texture2D(tb, gl_TexCoord[0].xy).rgb;
//gl_FragColor.rgb = v0.rgb;
}

View File

@@ -0,0 +1,6 @@
#version 130
void main(void) {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}

View File

@@ -0,0 +1,13 @@
#version 120
uniform sampler2D t0, depth;
uniform vec3 backColor;
void main(void) {
//gl_FragColor.rgb=vec3(1,1,1);
if (texture2D(depth, gl_TexCoord[0].xy).x == 1.) {
gl_FragColor.rgb = backColor;
return;
}
gl_FragColor.rgb = texture2D(t0, gl_TexCoord[0].xy).rgb;
}

View File

@@ -0,0 +1,6 @@
#version 120
void main(void) {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}

View File

@@ -0,0 +1,13 @@
#version 130
uniform sampler2D t0;
uniform vec2 vsize;
const vec3 luma = vec3(0.299, 0.587, 0.114);
void main(void) {
vec2 tc = gl_TexCoord[0].xy;//, dt = 1. / vsize;
vec3 dc0 = texture2D(t0, tc).rgb, dc1 = textureOffset(t0, tc, ivec2(1, 0)).rgb, dc2 = textureOffset(t0, tc, ivec2(0, 1)).rgb, dc3 = textureOffset(t0, tc, ivec2(1, 1)).rgb;
float l0 = dot(dc0, luma), l1 = dot(dc1, luma), l2 = dot(dc2, luma), l3 = dot(dc3, luma);
gl_FragColor.rgb = vec3(max(max(max(l0, l1), l2), l3), min(min(min(l0, l1), l2), l3), (l0 + l1 + l2 + l3) / 4.);
}

View File

@@ -0,0 +1,10 @@
#version 130
uniform sampler2D t0;
uniform vec2 vsize;
void main(void) {
vec2 tc = gl_TexCoord[0].xy;//, dt = 1. / vsize;
vec3 dc0 = texture2D(t0, tc).rgb, dc1 = textureOffset(t0, tc, ivec2(1, 0)).rgb, dc2 = textureOffset(t0, tc, ivec2(0, 1)).rgb, dc3 = textureOffset(t0, tc, ivec2(1, 1)).rgb;
gl_FragColor.rgb = vec3(max(max(max(dc0.r, dc1.r), dc2.r), dc3.r), min(min(min(dc0.g, dc1.g), dc2.g), dc3.g), (dc0.b + dc1.b + dc2.b + dc3.b) / 4.);
}

View File

@@ -0,0 +1,161 @@
#version 130
const float e = 2.7182818284;
const float pi = 3.1415926;
float Phong_diffuse(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
return max(dot(n, l), 0.);
}
float Phong_specular(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
return pow(max(dot(n, h), 0.), shininess);
}
float Cook_Torrance_diffuse(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
return max(dot(n, l), 0.);
}
float Cook_Torrance_specular(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
float NdotL = max( dot( n, l ), 0. );
float NdotV = max( dot( n, v ), 0. );
float NdotH = max( dot( n, h ), 1.e-7 );
float VdotH = max( dot( v, h ), 0. );
float geometric = 2. * NdotH / VdotH;
geometric = min(1., geometric * min(NdotV, NdotL));
float r_sq = 1. / (shininess * shininess);
float NdotH_sq = NdotH * NdotH;
float NdotH_sq_r = 1. / (NdotH_sq * r_sq);
float roughness_exp = (NdotH_sq - 1.) * (NdotH_sq_r);
float roughness = exp(roughness_exp) * NdotH_sq_r / (4. * NdotH_sq);
float fresnel = 1. / (1. + NdotV);
return min(1., (fresnel * geometric * roughness) / (NdotV * NdotL + 1.e-7));
}
float Minnaert_diffuse(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
return max(dot(n, l), 0.);
}
float Minnaert_specular(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
float k = shininess / 128.;
float d1 = pow(max(dot(n, l), 0.), 1. + k);
float d2 = pow(1. - dot(n, v), 1. - k);
return d1*d2;
}
float fresnel(float x, float kf) {
float dx = x - kf;
float d1 = 1.0 - kf;
float kf2 = kf * kf;
return (1.0 / (dx * dx) - 1.0 / kf2) / (1.0 / (d1 * d1) - 1.0 / kf2 );
//return 1.0;
}
float shadow(float x, float ks) {
float dx = x - ks;
float d1 = 1.0 - ks;
float ks2 = ks * ks;
//return (1.0 / (dx * dx) - 1.0 / ks2) / (1.0 / (d1 * d1) - 1.0 / ks2 );
return 1.0;
}
const float smooth_ = 0.5;
const float transp = 0;
const float k = 0.1;
const float kf = 1.12;
const float ks = 1.01;
float Strauss_diffuse(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
vec3 h2 = reflect(l, n);
float metal = shininess / 20.;
float nl = dot( n, l);
float nv = dot( n, v);
float hv = dot( h2, v);
float f = fresnel( nl, kf );
float s3 = smooth_ * smooth_ * smooth_;
// diffuse term
float d = ( 1.0 - metal * smooth_ );
float Rd = ( 1.0 - s3 ) * ( 1.0 - transp );
float diff = nl * d * Rd;
// inputs into the specular term
// composite the final result, ensuring
return max(diff, 0.);
}
float Strauss_specular(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
vec3 h2 = reflect(l, n);
float metal = shininess / 20.;
float nl = dot( n, l);
float nv = dot( n, v);
float hv = dot( h2, v);
float f = fresnel( nl, kf );
float s3 = smooth_ * smooth_ * smooth_;
// diffuse term
float d = ( 1.0 - metal * smooth_ );
float Rd = ( 1.0 - s3 ) * ( 1.0 - transp );
float diff = nl * d * Rd;
// inputs into the specular term
float r = (1.0 - transp) - Rd;
float j = f * shadow ( nl, ks ) * shadow ( nv, ks );
float refl = min ( 1.0, r + j * ( r + k ) );
float Cs = 1. + metal * (1.0 - f);
float spec = Cs * refl;
spec *= pow ( -hv, 3.0 / (1.0 - smooth_) );
// composite the final result, ensuring
return max(spec, 0.);
}
uniform float a, b;
float Oren_Nayar_diffuse(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
float nl = dot ( n, l );
float nv = dot ( n, v );
vec3 lProj = normalize ( l - n * nl );
vec3 vProj = normalize ( v - n * nv );
float cx = max ( dot ( lProj, vProj ), 0.0 );
float cosAlpha = nl > nv ? nl : nv;
float cosBeta = nl > nv ? nv : nl;
float dx = sqrt ( ( 1.0 - cosAlpha * cosAlpha ) * ( 1.0 - cosBeta * cosBeta ) ) / cosBeta;
return max(0. , nl) * (a + b * cx * dx);
//return max(dot(n, l), 0.);
}
float Oren_Nayar_specular(vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
return pow(max(dot(n, h), 0.), shininess);
}
/*
float light_diffuse(int model, vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
if (model == 0) return Phong_diffuse(l, n, h, v, shininess);
if (model == 1) return Cook_Torrance_diffuse(l, n, h, v, shininess);
if (model == 2) return Minnaert_diffuse(l, n, h, v, shininess);
if (model == 3) return Strauss_diffuse(l, n, h, v, shininess);
if (model == 4) return Oren_Nayar_diffuse(l, n, h, v, shininess);
return 0.;
}
float light_specular(int model, vec3 l, vec3 n, vec3 h, vec3 v, float shininess) {
if (model == 0) return Phong_specular(l, n, h, v, shininess);
if (model == 1) return Cook_Torrance_specular(l, n, h, v, shininess);
if (model == 2) return Minnaert_specular(l, n, h, v, shininess);
if (model == 3) return Strauss_specular(l, n, h, v, shininess);
if (model == 4) return Oren_Nayar_specular(l, n, h, v, shininess);
return 0.;
}*/

42
qglview/shaders/post.frag Normal file
View File

@@ -0,0 +1,42 @@
#version 130
uniform sampler2D t0, t1;//, t2;
uniform vec2 vsize;
uniform float clum;
uniform bool has_bloom;
float unpackDepth(vec4 dv) {
return dot(dv.rgb, vec3(65025., 255., 1.));
}
void main(void) {
vec2 tc = gl_TexCoord[0].xy;//, dt = 2. / vsize, dt2 = dt + dt;
vec4 bloom;
float tone = 1. / clum;
if (has_bloom) {
bloom = (texture2D(t1, tc) * 3. +
textureOffset(t1, tc, ivec2(2, 0)) * 2. +
textureOffset(t1, tc, ivec2(0, 2)) * 2. +
textureOffset(t1, tc, ivec2(-2, 0)) * 2. +
textureOffset(t1, tc, ivec2(0, -2)) * 2. +
textureOffset(t1, tc, ivec2(2, 2)) * 1.5 +
textureOffset(t1, tc, ivec2(2, -2)) * 1.5 +
textureOffset(t1, tc, ivec2(-2, -2)) * 1.5 +
textureOffset(t1, tc, ivec2(-2, 2)) * 1.5 +
textureOffset(t1, tc, ivec2(4, 0)) +
textureOffset(t1, tc, ivec2(0, 4)) +
textureOffset(t1, tc, ivec2(-4, 0)) +
textureOffset(t1, tc, ivec2(0, -4)) +
textureOffset(t1, tc, ivec2(4, 2)) +
textureOffset(t1, tc, ivec2(4, -2)) +
textureOffset(t1, tc, ivec2(-4, -2)) +
textureOffset(t1, tc, ivec2(-4, 2)) +
textureOffset(t1, tc, ivec2(2, 4)) +
textureOffset(t1, tc, ivec2(2, -4)) +
textureOffset(t1, tc, ivec2(-2, -4)) +
textureOffset(t1, tc, ivec2(-2, 4))) / 29.;
vec4 diff = texture2D(t0, tc);
gl_FragColor = max(diff * tone, bloom);// + vec4(0.01/(clum+0.1));
} else
gl_FragColor = texture2D(t0, tc) * tone;// + vec4(0.01/(clum+0.1));
}

178
qglview/shaders/ppl.frag Normal file
View File

@@ -0,0 +1,178 @@
#version 130
#define lc 4
varying vec4 diffuse[lc], pos, spos;//, ambient;//, col;
varying vec3 lightDir[lc]/*halfVector[lc], */;
//varying vec3 lightDir[lc]/*halfVector[lc], */;
varying vec3 normal, srcn;
varying float fogCoord, alpha;
uniform int lightsCount;
uniform bool acc_light, acc_fog, has_diffuse, has_bump, is_glass, shadows, soft_shadows;
uniform float bump_scale, reflectivity, iof, cdis;
uniform vec2 vsize;
uniform sampler2D t0, t1, t2;
uniform sampler2D s0;
uniform samplerCube tc, tc0;
uniform mat4 mat;
float light_diffuse(vec3 l, vec3 n, vec3 h, vec3 v, float shininess);
float light_specular(vec3 l, vec3 n, vec3 h, vec3 v, float shininess);
const float bias = 1.;
vec2 sp;
vec4 sc, dc;//ambient;
void calcLight(in int index, in vec3 n, in vec3 v) {
vec2 scoord, sdt, sdt2;
vec3 halfV, ldir;
vec4 lpos = gl_LightSource[index].position;
float spot, ldist = length(lpos.xyz - pos.xyz), shadow = 1., sdep, ddep;
ldir = normalize(lpos.xyz - (pos.xyz * lpos.w));
halfV = normalize(ldir + v);
//if (dot(ldir, n) > 0) {
spot = step(0., dot(ldir, n));
if (gl_LightSource[index].spotCutoff < 180.) {
spot = max(dot(-ldir, gl_LightSource[index].spotDirection.xyz), 0.);
spot *= step(gl_LightSource[index].spotExponent, spot);
spot = pow(spot, (gl_LightSource[index].spotCosCutoff + 0.001));
if (spot > 0. && shadows) {
scoord = (spos.xyz / spos.w).xy / 2 + vec2(0.5);
sdep = texture(s0, scoord.xy).r + bias;
ddep = pow((spos.z - sdep) / 4., 0.5) * 2.;
shadow = clamp(sdep - spos.z, 0., 1.);
if (soft_shadows) {
sdt = ddep / vsize;
sdt2 = sdt + sdt;
shadow += (clamp(texture(s0, scoord.xy + vec2(sdt.x, 0.)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(0, sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt.x, 0.)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(0, -sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt.x, sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt.x, -sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt.x, sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt.x, -sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt.x, 0)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(0, sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt.x, 0)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(0, -sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt.x, sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt.x, -sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt.x, -sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt.x, sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt2.x, 0)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(0, sdt2.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt2.x, 0)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(0, -sdt2.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt2.x, sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt2.x, -sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt2.x, -sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt2.x, sdt.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt.x, sdt2.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(sdt.x, -sdt2.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt.x, -sdt2.y)).r + bias - spos.z, 0., 1.) +
clamp(texture(s0, scoord.xy + vec2(-sdt.x, sdt2.y)).r + bias - spos.z, 0., 1.)) / 29.;
shadow = clamp(pow(shadow, 0.5), 0., 1);
}
spot *= shadow;
}
}
spot /= (gl_LightSource[index].constantAttenuation + ldist * (gl_LightSource[index].linearAttenuation + ldist * gl_LightSource[index].quadraticAttenuation));
dc += spot * diffuse[index] * light_diffuse(ldir, n, halfV, v, gl_FrontMaterial.shininess);
sc += spot * gl_FrontMaterial.specular * gl_LightSource[index].specular * light_specular(ldir, n, halfV, v, gl_FrontMaterial.shininess);
//}
}
void main(void) {
/*vec3 scoord = spos.xyz / spos.w;
float sdep = texture(s0, scoord.xy / 2 + vec2(0.5)).r + 1;
//gl_FragColor.rgb = vec3(step(spos.z, sdep));
gl_FragColor.rgb = vec3(spos.z - sdep)/10;
//gl_FragColor.rgb = vec3(texture(s0, scoord.xy+vec2(0.5)).r/100);
//gl_FragColor.rgb = vec3(texture(s0,).r/100);
return;*/
//bias = (vsize.x - vsize.y) / max(vsize.x, vsize.y)*5 - 1.;
if (!acc_light) {
if (has_diffuse) gl_FragColor = texture2D(t0, gl_TexCoord[0].xy);
//else gl_FragColor = gl_Color;
if (acc_fog)
gl_FragColor.xyz = mix(gl_FragColor.xyz, gl_Fog.color.xyz, fogCoord);
return;
}
sp = gl_FragCoord.xy / vsize;
vec3 n, v = normalize(-pos.xyz);
//v.xy = vec2(1,1)-gl_FragCoord.xy / vsize*2 ;//- vec2(1,1);
if (has_bump) n = normalize(normal + (texture2D(t1, gl_TexCoord[0].xy).xyz - vec3(0.5, 0.5, 1.)) * bump_scale);
else n = normalize(normal);
vec4 color;
sc = vec4(0.);
dc = gl_LightModel.ambient * gl_FrontMaterial.ambient;//ambient;
if (lightsCount > 0) {
calcLight(0, n, v);
if (lightsCount > 1) {
calcLight(1, n, v);
if (lightsCount > 2) {
calcLight(2, n, v);
if (lightsCount > 3) {
calcLight(3, n, v);
/*if (lightsCount > 4) {
calcLight(4, n, v);
if (lightsCount > 5) {
calcLight(5, n, v);
if (lightsCount > 6) {
calcLight(6, n, v);
if (lightsCount > 7) {
calcLight(7, n, v);
}
}
}
}*/
}
}
}
}
sc = max(sc, vec4(0.));
vec2 spr = sp, spg = sp, spb = sp, spc = sp, spm = sp, spy = sp, dsp;
vec3 bgf;
float fresnel = pow(1. - max(dot(v, n), 0.), 1);
dsp = fresnel * n.xy * (1. - iof);
spg += dsp;
if (cdis > 0.) {
spr += dsp * (1. - cdis - cdis);
spy += dsp * (1. - cdis);
spc += dsp * (1. + cdis);
spb += dsp * (1. + cdis + cdis);
vec3 bg0 = texture2D(t2, spr).rgb, bg1 = texture2D(t2, spy).rgb, bg2 = texture2D(t2, spg).rgb, bg3 = texture2D(t2, spc).rgb, bg4 = texture2D(t2, spb).rgb;
//bgf = vec3(bg0.r, bg2.g, bg4.b);
bgf = vec3((bg0.r + bg1.r) / 2., (bg1.g + bg2.g + bg3.g) / 3., (bg3.b + bg4.b) / 2.);
} else bgf = texture2D(t2, spg).rgb;
if (has_diffuse) {
vec4 tex = texture2D(t0, gl_TexCoord[0].xy);
dc *= tex;
color.a = tex.a * alpha;
} else color.a = alpha;
color.rgb = dc.rgb;
vec3 ln = vec3(0);
if (is_glass) {
ln = reflect(v, n);
ln = ln * mat3(gl_ModelViewMatrix);
ln.y = -ln.y;
color.rgb = (mix(bgf, textureCube(tc, ln).rgb, 0.2 + fresnel * 0.8) * gl_FrontMaterial.diffuse.rgb + gl_FrontMaterial.emission.rgb) + sc.rgb * color.a;
color.a = 1.;
} else {
if (reflectivity > 0.) {
ln = reflect(v, n);
ln = ln * mat3(gl_ModelViewMatrix);
ln.y = -ln.y;
color.rgb = mix(color.rgb, textureCube(tc, ln).rgb, reflectivity);
}
color.rgb = mix(color.rgb * gl_FrontMaterial.diffuse.rgb + gl_FrontMaterial.emission.rgb, bgf, 1. - alpha) + sc.rgb * color.a;
color.a = 1;
}
if (acc_fog)
color.rgb = mix(color.rgb, gl_Fog.color.rgb, fogCoord);
gl_FragColor = color;
//gl_FragColor.rgb = mix(ldir, texture2D(t2, sp).rgb, 1. - alpha);
}

66
qglview/shaders/ppl.vert Normal file
View File

@@ -0,0 +1,66 @@
#version 130
#define lc 4
varying vec4 diffuse[lc], pos, spos;//, ambient;//, col;
varying vec3 lightDir[lc]/*halfVector[lc], */;
//varying vec3 lightDir[lc]/*halfVector[lc], */;
varying vec3 normal, srcn;
varying float fogCoord, alpha;
uniform int lightsCount;
uniform bool acc_fog, shadows;
uniform mat4 mat;
void prepareLight(in int index, in vec3 p) {
vec4 lpos = gl_LightSource[index].position;
lightDir[index] = normalize(lpos.xyz - (p * lpos.w));
//halfVector[index] = normalize(lightDir[index] - normalize(p));
diffuse[index] = gl_FrontMaterial.diffuse * gl_LightSource[index].diffuse;
}
void main(void) {
float NdotL;
//col = gl_Color;
alpha = gl_Color.a;
normal = normalize(gl_NormalMatrix * gl_Normal);
srcn = gl_Normal;
pos = gl_ModelViewMatrix * gl_Vertex;
//v = normalize(-pos);
if (acc_fog) {
fogCoord = (gl_Fog.end - length(pos) * 0.85) / (gl_Fog.end - gl_Fog.start);
fogCoord = 1. - clamp(fogCoord, 0., 1.);
}
vec3 ldir;
if (lightsCount > 0) {
prepareLight(0, pos.xyz);
if (lightsCount > 1) {
prepareLight(1, pos.xyz);
if (lightsCount > 2) {
prepareLight(2, pos.xyz);
if (lightsCount > 3) {
prepareLight(3, pos.xyz);
diffuse[3] = gl_FrontMaterial.diffuse * gl_LightSource[3].diffuse;
/*if (lightsCount > 4) {
diffuse[4] = gl_FrontMaterial.diffuse * gl_LightSource[4].diffuse;
if (lightsCount > 5) {
diffuse[5] = gl_FrontMaterial.diffuse * gl_LightSource[5].diffuse;
if (lightsCount > 6) {
diffuse[6] = gl_FrontMaterial.diffuse * gl_LightSource[6].diffuse;
if (lightsCount > 6) {
diffuse[7] = gl_FrontMaterial.diffuse * gl_LightSource[7].diffuse;
}
}
}
}*/
}
}
}
}
//ambient = gl_LightModel.ambient * gl_FrontMaterial.ambient;
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_TexCoord[1] = gl_MultiTexCoord1;
gl_TexCoord[2] = gl_MultiTexCoord2;
gl_TexCoord[3] = gl_MultiTexCoord3;
gl_Position = ftransform();
spos = pos * mat;
}

View File

@@ -0,0 +1,7 @@
#version 120
uniform vec4 id;
void main(void) {
gl_FragColor = id;
}

View File

@@ -0,0 +1,5 @@
#version 120
void main(void) {
gl_Position = ftransform();
}

View File

@@ -0,0 +1,18 @@
#version 130
uniform vec2 dt;
uniform vec4 selected, color;
uniform sampler2D t0;
uniform float fill;
void main(void) {
vec4 ds0 = abs(textureLodOffset(t0, gl_TexCoord[0].xy, 0., ivec2(-1, 0)) - selected);
vec4 ds1 = abs(textureLodOffset(t0, gl_TexCoord[0].xy, 0., ivec2( 1, 0)) - selected);
vec4 ds2 = abs(textureLodOffset(t0, gl_TexCoord[0].xy, 0., ivec2(0, -1)) - selected);
vec4 ds3 = abs(textureLodOffset(t0, gl_TexCoord[0].xy, 0., ivec2(0, 1)) - selected);
float d0 = dot(ds0, vec4(1., 1., 1., 1.)), d1 = dot(ds1, vec4(1., 1., 1., 1.)), d2 = dot(ds2, vec4(1., 1., 1., 1.)), d3 = dot(ds3, vec4(1., 1., 1., 1.));
float vs = step(1e-6, d0 + d1 + d2 + d3);
float vm = step(1e-3, (d0 * 255.) * (d1 * 255.) * (d2 * 255.) * (d3 * 255.));
float v = mix(vs - vm, vs - vm - vm + 1, fill);
gl_FragColor = vec4(color.rgb, v * color.a);
}

View File

@@ -0,0 +1,6 @@
#version 130
void main(void) {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}

View File

@@ -0,0 +1,5 @@
#version 130
void main(void) {
gl_FragColor.r = 1. / gl_FragCoord.w;
}

View File

@@ -0,0 +1,6 @@
#version 130
void main(void) {
gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}

View File

@@ -0,0 +1,9 @@
#version 200
//in vec3 src_normal, normal, et;
in vec3 wpos;
void main(void) {
//vec2 tc = gl_TexCoord[0].xy;
gl_FragColor.xyz = wpos * 1E+6;
}

13
qglview/shaders/test.geom Normal file
View File

@@ -0,0 +1,13 @@
#version 300 core
layout(triangles, invocations = 1) in;
//in vec3 normal[];
void main() {
for (int i = 0; i < gl_in.length(); i++ ) {
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
EndPrimitive();
}

11
qglview/shaders/test.vert Normal file
View File

@@ -0,0 +1,11 @@
#version 300 core
//in vec3 src_normal, normal, et;
out vec3 wpos;
void main(void) {
//vec2 tc = gl_TexCoord[0].xy;
wpos = gl_Vertex.xyz;
//gl_TexCoord[0] = gl_MultiTexCoord0;
gl_Position = ftransform();
}