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

This commit is contained in:
2019-09-02 14:08:38 +00:00
parent f862381b68
commit 3d06d2095e
929 changed files with 66799 additions and 0 deletions

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);
}

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,8 @@
#version 150
uniform sampler2D t0;
uniform float factor = 1., threshold = 0.8;
void main(void) {
qgl_FragData[0].rgb = max(texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb - vec3(threshold), vec3(0.)) * factor;
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,55 @@
#version 150
uniform sampler2D t0;
uniform int radius = 2;
uniform vec2 dt;
void main(void) {
vec2 tc = qgl_FragTexture.xy;
float r = float(radius);
int o = radius, o2 = radius * 2;
vec3 scol = (texture(t0, tc).rgb * 3. +
texture(t0, tc + dt * vec2( o, 0 )).rgb * 2. +
texture(t0, tc + dt * vec2( 0, o )).rgb * 2. +
texture(t0, tc + dt * vec2( -o, 0 )).rgb * 2. +
texture(t0, tc + dt * vec2( 0, -o)).rgb * 2. +
texture(t0, tc + dt * vec2( o, o )).rgb * 1.5 +
texture(t0, tc + dt * vec2( o, -o)).rgb * 1.5 +
texture(t0, tc + dt * vec2( -o, -o )).rgb * 1.5 +
texture(t0, tc + dt * vec2( -o, o )).rgb * 1.5 +
texture(t0, tc + dt * vec2( o2, 0 )).rgb +
texture(t0, tc + dt * vec2( 0, o2)).rgb +
texture(t0, tc + dt * vec2(-o2, 0 )).rgb +
texture(t0, tc + dt * vec2( 0, -o2)).rgb +
texture(t0, tc + dt * vec2( o2, o )).rgb +
texture(t0, tc + dt * vec2( o2, -o)).rgb +
texture(t0, tc + dt * vec2(-o2, -o )).rgb +
texture(t0, tc + dt * vec2(-o2, o )).rgb +
texture(t0, tc + dt * vec2( o, o2)).rgb +
texture(t0, tc + dt * vec2( o, -o2)).rgb +
texture(t0, tc + dt * vec2( -o, -o2)).rgb +
texture(t0, tc + dt * vec2( -o, o2)).rgb) / 29.;
/*vec3 scol = (texelFetch(t0, tc, 0).rgb * 3. +
texelFetch(t0, tc + ivec2( o, 0 ), 0).rgb * 2. +
texelFetch(t0, tc + ivec2( 0, o ), 0).rgb * 2. +
texelFetch(t0, tc + ivec2( -o, 0 ), 0).rgb * 2. +
texelFetch(t0, tc + ivec2( 0, -o), 0).rgb * 2. +
texelFetch(t0, tc + ivec2( o, o ), 0).rgb * 1.5 +
texelFetch(t0, tc + ivec2( o, -o), 0).rgb * 1.5 +
texelFetch(t0, tc + ivec2( -o, -o ), 0).rgb * 1.5 +
texelFetch(t0, tc + ivec2( -o, o ), 0).rgb * 1.5 +
texelFetch(t0, tc + ivec2( o2, 0 ), 0).rgb +
texelFetch(t0, tc + ivec2( 0, o2), 0).rgb +
texelFetch(t0, tc + ivec2(-o2, 0 ), 0).rgb +
texelFetch(t0, tc + ivec2( 0, -o2), 0).rgb +
texelFetch(t0, tc + ivec2( o2, o ), 0).rgb +
texelFetch(t0, tc + ivec2( o2, -o), 0).rgb +
texelFetch(t0, tc + ivec2(-o2, -o ), 0).rgb +
texelFetch(t0, tc + ivec2(-o2, o ), 0).rgb +
texelFetch(t0, tc + ivec2( o, o2), 0).rgb +
texelFetch(t0, tc + ivec2( o, -o2), 0).rgb +
texelFetch(t0, tc + ivec2( -o, -o2), 0).rgb +
texelFetch(t0, tc + ivec2( -o, o2), 0).rgb) / 29.;*/
qgl_FragData[0].rgb = scol;
//qgl_FragData[0].rgb = vec3(r/10.);
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,47 @@
#version 150
uniform float z_near, z_far;
uniform sampler2D t0, td;
uniform vec2 dt;
uniform float radius, focus, diaphragm;
float w, sum;
const float _pe = 2.4e-7;
vec4 getTexel(vec2 c, float coeff) {
vec4 ret = texture(t0, c);
float cw = texture(td, c).r;
cw = clamp(1. - abs(cw - w) * 1000, 0., 1.) * coeff;
sum += cw;
return ret * cw;
}
void main(void) {
vec2 tc = qgl_FragTexture.xy;
vec4 scol = texture(t0, tc);
w = texture(td, tc).r;
float z = w + w - 1;
z = ((_pe - 2.) * z_near) / (z + _pe - 1.); // infinite depth
z = 1./(z + 1);
float cf = 1./(focus + 1);
float factor = clamp(abs(z - cf) * diaphragm, 0, 100);
factor = 1. - 1. / (factor + 1.);
factor *= factor;
factor *= factor;
//factor *= factor;
factor *= radius;
vec2 cdt = factor * dt;
sum = 1.;
scol += getTexel(tc + (cdt * 1), 2.5);
scol += getTexel(tc + (cdt * 2), 2.0);
scol += getTexel(tc + (cdt * 3), 1.5);
scol += getTexel(tc + (cdt * 4), 1.0);
scol += getTexel(tc + (cdt * 5), 0.5);
scol += getTexel(tc + (cdt * -1), 2.5);
scol += getTexel(tc + (cdt * -2), 2.0);
scol += getTexel(tc + (cdt * -3), 1.5);
scol += getTexel(tc + (cdt * -4), 1.0);
scol += getTexel(tc + (cdt * -5), 0.5);
scol /= sum;
qgl_FragData[0].rgba = scol;
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,7 @@
#version 150
uniform sampler2D t0;
void main(void) {
qgl_FragData[0].rgb = textureLod(t0, qgl_FragTexture.xy, 3).rgb;
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,67 @@
#version 150
//#extension GL_ARB_conservative_depth: enable
//layout(depth_less) out float gl_FragDepth;
in vec3 src_normal, normal, binormal;//, et;
in vec4 pos, ppos;
in float fogCoord, FC, C;
in mat3 TBN;
uniform bool acc_fog;
uniform vec2 dt;
uniform float z_far, z_near;
const vec3 luma = vec3(0.299, 0.587, 0.114);
void main(void) {
//float z = pos.w;//((z_near / (z_near-z_far)) * z_far) / (pos.w - (z_far / (z_far-z_near)));
//float logz = log(pos.w * C + 1.) * FC;
vec4 dc = qgl_FragColor;
vec2 tc = qgl_FragTexture.xy;
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
vec3 n, dn, bn;
dn = texture(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.);
dn = dn * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
dn.y = -dn.y;
dn = TBN * dn;
//dn.z = 0;
n = normalize(qgl_NormalMatrix * (normal + dn));
bn = normalize(qgl_NormalMatrix * binormal);
//n = dn;
dc *= texture(qgl_Material.map_diffuse.map, tc) * qgl_Material.map_diffuse.amount + qgl_Material.map_diffuse.offset;
vec4 spec = texture(qgl_Material.map_specular.map, tc) * qgl_Material.map_specular.amount + qgl_Material.map_specular.offset;
spec *= qgl_Material.color_specular;
float specularity = dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
specularity = clamp(specularity, 0.05, 0.99);
float reflectivity = qgl_Material.reflectivity;//dot(texture(qgl_Material.map_specularity.map, tc).rgb, luma) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
reflectivity = clamp(reflectivity, 0., 1.);
vec4 self = texture(qgl_Material.map_self_illumination.map, tc) * qgl_Material.map_self_illumination.amount + qgl_Material.map_self_illumination.offset;
self *= qgl_Material.color_self_illumination;
vec3 speed = pos.xyz/pos.w - ppos.xyz/ppos.w;
//speed /= abs(pos.z);
//gl_FragDepth = logz;
qgl_FragData[0] = vec4(dc.rgb, 0.);
qgl_FragData[1] = vec4(n.xyz, specularity + round(reflectivity * 100));
qgl_FragData[2] = vec4(spec.rgb, hei);
qgl_FragData[3] = vec4(self.rgb, bn.x);
qgl_FragData[4] = vec4(speed.xy, bn.yz);
//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,46 @@
#version 150
out vec3 src_normal, normal, binormal;//, et;
out vec4 pos, ppos;
out float fogCoord, FC, C;
out mat3 TBN;
uniform bool acc_fog;
uniform vec2 dt;
uniform vec3 eye;
uniform mat4 prev_ModelViewProjectioMatrix;
uniform float z_near, z_far;
void main(void) {
normal = qgl_Normal;//(qgl_NormalMatrix * qgl_Normal);
binormal = qgl_Bitangent;//(qgl_NormalMatrix * qgl_Normal);
pos = qgl_ftransform();
TBN = mat3(qgl_Tangent, qgl_Bitangent, qgl_Normal);
/*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;
src_normal = normalize(vec3(pos.xy * dt * 2., 0));
qgl_FragTexture = qgl_Texture;
qgl_FragColor = qgl_Color;
//tp /= tp.w;
ppos = prev_ModelViewProjectioMatrix * qgl_Vertex;
//pos.w = pos.w;
//speed = tp - ppos;
//speed /= (abs(speed) + 1.);
//speed.xyz *= speed.w;
//pos *= pos.w;
//logz = gl_Position.w*C + 1; //version with fragment code
C = 0.01;
FC = 1. / log(z_far * C + 1.);
//pos.z = (logz + logz - 1) * pos.w;
gl_Position = pos;
}

View File

@@ -0,0 +1,166 @@
#version 150
//#extension GL_EXT_gpu_shader4 : enable
in vec3 view_dir;
in vec4 view_pos;
uniform vec3 ambient;
uniform sampler2D t0, t1, t2, t3, t4, t_pp;
uniform sampler2D td;
uniform int gid, lightsCount, shadow_on;
uniform float z_near, z_far;
uniform bool firstPass;
uniform vec2 dt;
uniform vec4 back_color;
uniform mat4 mat_proji, mat_view, mat_viewi, mat_viewproji;
float light_diffuse(int model, vec3 l, vec3 n) {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, shp;
vec3 li, si, ldir, halfV, bn, bn2, lwdir;
vec3 vds, vds2;
float sh_pow, sh_mul, dist, NdotL, NdotH, spot, ldist, diff, sdist, shadow;
float getShadow(int light, vec3 view_pos, vec3 dpos) {
shp = qgl_Light[light].shadowMatrix * vec4(view_pos + dpos, 1);
shp.z -= z_near / 20.;
return textureProj(qgl_Light[light].shadow, shp);
}
void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
lpos = qgl_Light[index].position;
ldir = lpos.xyz - (pos.xyz * lpos.w);
ldist = length(ldir);
ldir = normalize(ldir);
halfV = normalize(ldir + v);
NdotL = max(dot(n, ldir), 0.0001);
NdotH = max(dot(n, halfV), 0.0001);
spot = step(0., NdotL) * qgl_Light[index].intensity;
if (qgl_Light[index].endAngle <= 90.) {
float scos = max(dot(-ldir, qgl_Light[index].direction.xyz), 0.);
spot *= scos * step(qgl_Light[index].endAngleCos, scos);
spot *= smoothstep(qgl_Light[index].endAngleCos, qgl_Light[index].startAngleCos, scos);
lwdir = mat3(mat_viewi) * qgl_Light[index].direction.xyz;
//bn = normalize(cross(lwdir, vec3(1, 0, 0)));
//bn2 = normalize(cross(lwdir, bn));
float ds = ldist/200.;//max(abs(sdist) / 5000, 0.02);
//spot *= clamp(1. - sdist, 0, 1);
vds = ds * bn.xyz;
vds2 = ds * bn2.xyz;
float shadow = getShadow(index, pos.xyz, vec3(0)) * 3. +
getShadow(index, pos.xyz, vds ) * 2. +
getShadow(index, pos.xyz, - vds ) * 2. +
getShadow(index, pos.xyz, - vds2 ) * 2. +
getShadow(index, pos.xyz, + vds2 ) * 2. +
getShadow(index, pos.xyz, vds - vds2 ) * 1.5 +
getShadow(index, pos.xyz, vds + vds2 ) * 1.5 +
getShadow(index, pos.xyz, - vds - vds2 ) * 1.5 +
getShadow(index, pos.xyz, - vds + vds2 ) * 1.5 +
getShadow(index, pos.xyz, vds + vds ) +
getShadow(index, pos.xyz, - vds - vds ) +
getShadow(index, pos.xyz, - vds2 - vds2) +
getShadow(index, pos.xyz, + vds2 + vds2) +
getShadow(index, pos.xyz, vds + vds - vds2 ) +
getShadow(index, pos.xyz, - vds - vds - vds2 ) +
getShadow(index, pos.xyz, vds + vds + vds2 ) +
getShadow(index, pos.xyz, - vds - vds + vds2 ) +
getShadow(index, pos.xyz, vds - vds2 - vds2) +
getShadow(index, pos.xyz, vds + vds2 + vds2) +
getShadow(index, pos.xyz, - vds - vds2 - vds2) +
getShadow(index, pos.xyz, - vds + vds2 + vds2);
spot *= mix(1., shadow / 29., shadow_on);
}
spot /= (qgl_Light[index].constantAttenuation + ldist * (qgl_Light[index].linearAttenuation + ldist * qgl_Light[index].quadraticAttenuation));
///li += spot * gl_LightSource[index].diffuse.rgb * light_diffuse(0, ldir, n);
//si += spot * qgl_Light[index].color.rgb * sh_mul * light_specular(0, ldir, n, halfV, v, sh_pow);
float NdotLs = NdotL*NdotL;
float NdotHs = NdotH*NdotH;
float ndlc = (1. - NdotLs) / NdotLs;
float der = NdotLs * (sh_mul + ndlc);
diff = 2. / (1. + sqrt(1. + (1. - sh_mul) * ndlc));
li += spot * qgl_Light[index].color.rgb * diff;// * light_diffuse(0, ldir, n);
ndlc = (1. - NdotHs) / NdotHs;
der = NdotHs * (sh_mul + ndlc);
si += spot * qgl_Light[index].color.rgb * (sh_mul / (der*der) / 3.1416);
}
const float _pe = 2.4e-7;
void main(void) {
//if (d == 1.) discard;
ivec2 tc = ivec2(gl_FragCoord.xy);
float z = texelFetch(td, tc, 0).r;
if (z == 1.) {
qgl_FragData[0] = back_color;
return;
}
vec4 v0 = texelFetch(t0, tc, 0),
v1 = texelFetch(t1, tc, 0),
v2 = texelFetch(t2, tc, 0),
v3 = texelFetch(t3, tc, 0),
v4 = texelFetch(t4, tc, 0);
z = z + z - 1;
z = ((_pe - 2.) * z_near) / (z + _pe - 1.); // infinite depth
vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
vec3 dc = v0.rgb, n = v1.xyz;
bn = normalize(vec3(v3.w, v4.zw));
bn2 = normalize(cross(n, bn));
float height = v2.w;
li = qgl_AmbientLight.color.rgb * qgl_AmbientLight.intensity;
si = vec3(0.);
/*float posz = z_near * z_far / (texelFetch(td, tc, 0).r * (z_far - z_near) - z_far);
pos = vec4(sp, 0., 1) * mat_proji;
pos.xy *= v0.z;
pos.z = posz;*/
pos.w = 1;
pos.xyz = view_dir * z;
pos.z = -pos.z;
//pos.z = posz;
//pos.xyz += n * height;
//pos.xyz = v3.xyz;
//pos = v3;
//pos = vec4(sp, 0, 1.) * mat_proji;
//pos *= v0.w;
//pos.z += 1;
//pos.xy *= 10.;
//pos.z = v0.w;
vec3 v = normalize(-pos.xyz);
float reflectivity = 0.;
float specularity = modf(v1.w, reflectivity);
sh_pow = 1. / max((1. - specularity), 0.0001);
sh_mul = max(1. - specularity, 0.0001);
for (int i = 0; i < 8; ++i)
calcLight(i, n, v, v2);
// calcLight(0, n, v, v2);
qgl_FragData[0] = vec4(max(vec3(0), li * dc + si * v2.rgb + v3.rgb + texelFetch(t_pp, tc, 0).rgb), v0.w);
//qgl_FragData[0].rgb = vec3(-z);
//qgl_FragData[0].rgb = li + vec3(texelFetch(t_pp, tc, 0).xyz);
//shd = shd - shp.w;
/*vec3 fp = pos.xyz;// * lpos.w;
vec3 _dlp = fp - qgl_Light[0].position.xyz;
vec3 _ld = qgl_Light[0].direction.xyz;
float lz = dot(_ld, _dlp);
vec3 _lt = normalize(cross(_ld, _dlp));
vec3 _lt2 = normalize(cross(_lt, _dlp));
float ly = dot(qgl_Light[0].shadowDir0.xyz, normalize(_dlp));
float lx = dot(qgl_Light[0].shadowDir1.xyz, normalize(_dlp));
vec3 dd = mat3(mat_viewi)*(normalize(_dlp) - _ld);
//qgl_FragData[0].rgb = vec3(abs(shp.xy/shp.w)/1,0);
float Y = dot(_dlp, qgl_Light[0].shadowDir0.xyz) / length(qgl_Light[0].shadowDir0.xyz);
float X = dot(_dlp, qgl_Light[0].shadowDir1.xyz) / length(qgl_Light[0].shadowDir1.xyz);
qgl_FragData[0].rgb = vec3(abs((mat3(mat_viewi)*_dlp).x)/100);*/
//qgl_FragData[0].rgb = vec3(abs(mat3(mat_viewi)* qgl_Light[0].direction.xyz));
//qgl_FragData[0].rgb = vec3(texture(qgl_Light[0].shadow,shp.xyz/shp.w)/2);
//qgl_FragData[0].a = 0.;
}

View File

@@ -0,0 +1,14 @@
#version 150
in vec3 view_corner;
out vec3 view_dir;
out vec4 view_pos;
void main(void) {
view_dir = view_corner / view_corner.z;
view_pos = vec4(qgl_ModelViewMatrix * vec4(qgl_Vertex.xy, 1, 1));
view_pos /= view_pos.w;
qgl_FragTexture = qgl_Texture;
qgl_FragColor = qgl_Color;
gl_Position = qgl_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,7 @@
#version 150
uniform sampler2D t0, t1;
void main(void) {
qgl_FragData[0].rgb = texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb + texelFetch(t1, ivec2(gl_FragCoord.xy), 0).rgb;
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,29 @@
#version 150
uniform sampler2D t0;
uniform float exposure;
float tA = 0.15;
float tB = 0.50;
float tC = 0.10;
float tD = 0.20;
float tE = 0.02;
float tF = 0.30;
float tW = 11.2;
vec3 Uncharted2Tonemap(vec3 x) {
return ((x*(tA*x+tC*tB)+tD*tE)/(x*(tA*x+tB)+tD*tF))-tE/tF;
}
void main(void) {
//qgl_FragData[0].rgb = texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb;
//return;
vec3 inColor = texelFetch(t0, ivec2(gl_FragCoord.xy), 0).rgb;
inColor *= exposure / 1.45;
float ExposureBias = 1.;
vec3 curr = Uncharted2Tonemap(ExposureBias*inColor);
vec3 whiteScale = 1. / Uncharted2Tonemap(vec3(tW));
vec3 color = curr * whiteScale;
vec3 retColor = color;//pow(color, vec3(1 / 1));
qgl_FragData[0].rgb = retColor;
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_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.;
}*/

View File

@@ -0,0 +1,24 @@
#version 150
uniform sampler2D t0, ts;
uniform vec2 dt;
uniform float factor = 1.;
uniform int steps = 8;
void main(void) {
vec2 cdt = dt / steps;
vec2 ct = qgl_FragTexture.xy;
vec3 speed = texelFetch(ts, ivec2(gl_FragCoord.xy), 0).rgb * 256 * factor;
int hsteps = steps / 2;
ct -= speed.xy * cdt * hsteps;
vec3 scol = vec3(0);//texture(t0, ct).rgb;
float sum = 0.;
for (int i = 0; i < steps; ++i) {
ct += speed.xy * cdt;
float mul = 1. - abs(i - hsteps) * 2. / steps;
scol += texture(t0, ct).rgb * mul;
sum += mul;
}
scol /= sum;
qgl_FragData[0].rgb = scol;
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

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));
}

View File

@@ -0,0 +1,179 @@
#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);
color.r = 250;
gl_FragColor = color;
//gl_FragColor.rgb = mix(ldir, texture2D(t2, sp).rgb, 1. - alpha);
}

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 150
uniform vec4 id;
void main(void) {
qgl_FragData[0] = id;
}

View File

@@ -0,0 +1,8 @@
#version 150
uniform float z_near, z_far;
void main(void) {
vec4 pos = qgl_ftransform();
gl_Position = pos;
}

View File

@@ -0,0 +1,20 @@
#version 150
uniform vec2 dt;
uniform vec4 selected, color;
uniform sampler2D t0;
uniform float fill;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec4 ds0 = abs(texelFetchOffset(t0, tc, 0, ivec2(-1, 0)) - selected);
vec4 ds1 = abs(texelFetchOffset(t0, tc, 0, ivec2( 1, 0)) - selected);
vec4 ds2 = abs(texelFetchOffset(t0, tc, 0, ivec2(0, -1)) - selected);
vec4 ds3 = abs(texelFetchOffset(t0, tc, 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 * 25.) * (d1 * 25.) * (d2 * 255.) * (d3 * 255.));
float v = mix(vs - vm, vs - vm - vm + 1, fill);
//qgl_FragData[0] = vec4(1,0,0,0.5);//vec4(color.rgb, v * color.a);
qgl_FragData[0] = vec4(color.bgr, v * color.a);
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,7 @@
#version 150
in float w;
void main(void) {
//;qgl_FragData[0].r = w;
}

View File

@@ -0,0 +1,10 @@
#version 150
out float w;
void main(void) {
qgl_FragTexture = qgl_Texture;
vec4 pos = qgl_ftransform();
w = pos.w;
gl_Position = pos;
}

View File

@@ -0,0 +1,55 @@
#version 150
uniform sampler2D t0, ts, tg1;
uniform float radius = 2;
uniform vec2 dt;
vec4 st;
vec4 getTexel(vec2 tc, vec4 ptc, float mul) {
vec4 tv = texture(t0, tc), ts = texture(ts, tc);
if (radius == 1) {
tv = vec4(tv.w);
ts = tv;
}
return vec4(min(ptc.r, ts.r), max(ptc.g, ts.g), ptc.b + /*mix(tv.b, st.b, clamp(abs(st.w - tv.w), 0, 1))*/tv.b * mul, 0);
}
void main(void) {
ivec2 itc = ivec2(gl_FragCoord.xy);
vec4 vg1 = texelFetch(tg1, itc, 0);
vec2 tc = qgl_FragTexture.xy;
float o = radius, o2 = radius * 2;
vec4 scol = texture(t0, tc);
if (radius == 1)
scol = vec4(scol.w);
st = scol;
scol.b *= 3.;
scol = getTexel(tc + dt * vec2( o, 0 ), scol, 2);
scol = getTexel(tc + dt * vec2( 0, o ), scol, 2);
scol = getTexel(tc + dt * vec2( -o, 0 ), scol, 2);
scol = getTexel(tc + dt * vec2( 0, -o), scol, 2);
scol = getTexel(tc + dt * vec2( o, o ), scol, 1.5);
scol = getTexel(tc + dt * vec2( o, -o), scol, 1.5);
scol = getTexel(tc + dt * vec2( -o, -o ), scol, 1.5);
scol = getTexel(tc + dt * vec2( -o, o ), scol, 1.5);
scol = getTexel(tc + dt * vec2( o2, 0 ), scol, 1);
scol = getTexel(tc + dt * vec2( 0, o2), scol, 1);
scol = getTexel(tc + dt * vec2(-o2, 0 ), scol, 1);
scol = getTexel(tc + dt * vec2( 0, -o2), scol, 1);
scol.b /= 21.;
/*vec4 scol = fp;
scol = min(scol, getTexel(tc + dt * vec2( o, 0 ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( 0, o ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( -o, 0 ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( 0, -o), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( o, o ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( o, -o), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( -o, -o ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( -o, o ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( o2, 0 ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( 0, o2), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2(-o2, 0 ), fp, fps));
scol = min(scol, getTexel(tc + dt * vec2( 0, -o2), fp, fps));*/
qgl_FragData[0].rgba = vec4(scol.rgb, texture(t0, tc).w);
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,53 @@
#version 150
uniform sampler2D t0, ts, tg1;
uniform sampler1D n0;
uniform float z_near, z_far;
uniform mat4 mat_proj;
in vec3 view_dir;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec4 v0 = texelFetch(t0, tc, 0), vs = texelFetch(ts, tc, 0), vg1 = texelFetch(tg1, tc, 0);
vec3 n = vec3(vg1.xyz);
vec3 bn = cross(n, vec3(0, 0, 1));
vec3 bn2 = cross(n, bn);
vec4 pos;
pos.w = 1;
pos.xyz = view_dir * vs.w;
vec4 spos = pos, tpos, tv0;
vec2 tsp;
float sclz = dot(vec3(0,0,1), n);
/*float l = 20 * 0.5;
pos.xyz += bn2 * l;
for (int i = 0; i < 16; ++i) {
tpos = mat_proj * pos;
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
tv0 = texture(ts, tsp);
l *= 0.5;
pos.xyz += bn2 * (step(pos.z, tv0.w) * 2. - 1.) * l;
}*/
/*vec3 rn;
float ss = 0.;
for (int i = 0; i < 32; ++i) {
rn = texelFetch(n0, i, 0).rgb * 2 - 1;
rn *= step(0., dot(n, rn)) * 2 - 1.;
//rn /= 10;
rn /= vs.w;
spos = pos + vec4(rn, 0);
tpos = mat_proj * spos;
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
tv0 = texture(ts, tsp);
//spos.z = tv0.w;
ss += step(-0.1, tv0.w-vs.w);
//ss += step(vs.w, tv0.w);
}
ss /= 32;*/
float minz = v0.r, maxz = v0.g, blurz = v0.b, curz = v0.w, avgz = (minz+maxz)/2;
float dz = maxz - minz;
//qgl_FragData[0].rgb = vec3(max(-(blurz - curz) / maxz,0.)* (curz-minz) / dz * 10);
qgl_FragData[0].rgb = vec3(blurz/10);
//qgl_FragData[0].rgb = vec3(length(pos.z - spos.z)/15);
//qgl_FragData[0].rgb = vec3(abs(v0.w/1));
}

View File

@@ -0,0 +1,10 @@
#version 150
in vec3 view_corner;
out vec3 view_dir;
void main(void) {
view_dir = view_corner / view_corner.z;
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,67 @@
#version 150
uniform sampler2D t0, t1, ts, td, tbs;
uniform float z_near, z_far;
uniform mat4 mat_proj;
uniform vec3 cam_aim, cam_pos;
in vec3 view_dir;
const float _pe = 2.4e-7;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec4 v0 = texelFetch(t0, tc, 0), v1 = texelFetch(t1, tc, 0), vs = texelFetch(ts, tc, 0);
vec3 sp = vec3(qgl_FragTexture.xy, v0.w);
vec2 tsp;
vec4 pos;
float z = texelFetch(td, tc, 0).r;
z = z + z - 1;
z = ((_pe - 2.) * z_near) / (z + _pe - 1.); // infinite depth
pos.w = 1;
pos.xyz = view_dir * z;
//pos.z = -pos.z;
vec4 spos = pos;
vec4 tpos;
vec3 dc = v0.rgb, n = v1.xyz;
vec3 vd = -normalize(vec3(-view_dir.xy, view_dir.z));
vec3 rn = reflect(vd, n);
//rn.z += 1.;
float coeff = clamp(1. - (dot(vec3(0,0,1), n)), 0, 1);
coeff = coeff*coeff;
/*coeff = coeff*coeff;
coeff = coeff*coeff;
coeff = coeff*coeff;*/
float reflectivity = 0.;
float specularity = modf(v1.w, reflectivity);
rn.z = -rn.z;
int i = 0;
vec4 tv0;
float l = z_far * 0.5;
pos.xyz += rn * l;
float cz;
for (i = 0; i < 24; ++i) {
tpos = mat_proj * pos;
tsp = -(tpos.xy / tpos.w) / 2. + 0.5;
cz = texture(td, tsp).r;
cz = cz + cz - 1;
cz = ((_pe - 2.) * z_near) / (cz + _pe - 1.); // infinite depth
l *= 0.5;
pos.xyz += rn * (step(pos.z, cz) * 2. - 1.) * l;
}
vec2 ess = abs(tsp - vec2(0.5, 0.5)) - vec2(0.3, 0.3);
ess = clamp(ess, vec2(0, 0), vec2(0.2, 0.2));
ess = smoothstep(vec2(0.2, 0.2), vec2(0, 0), ess);
coeff *= min(ess.x, ess.y);
vec4 pr_pos = mat_proj * pos, pr_spos = mat_proj * spos;
pr_pos.xyz /= pr_pos.w;
pr_spos.xyz /= pr_spos.w;
float blur = step(0., coeff) * length(pr_pos.xyz - pr_spos.xyz) * (1. - specularity);
vec3 rvs = texture(ts, tsp).rgb;
qgl_FragData[0] = vec4(rvs.rgb, coeff / 1.1 + clamp(round(blur * 10), 0, 1000));
//qgl_FragData[0] = vec4(rvs.rgb, cz/5);
}

View File

@@ -0,0 +1,10 @@
#version 150
in vec3 view_corner;
out vec3 view_dir;
void main(void) {
view_dir = view_corner / view_corner.z;
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,38 @@
#version 150
uniform sampler2D t0;
uniform float radius = 2;
uniform vec2 dt;
void main(void) {
vec2 tc = qgl_FragTexture.xy;
float r = float(radius);
vec4 v0 = texture(t0, tc);
float rad;
float coeff = modf(v0.w, rad) * 1.1;
rad /= 10.;
rad *= 2;
float o = radius * rad, o2 = radius * rad * 2;
vec3 scol = (v0.rgb * 3. +
texture(t0, tc + dt * vec2( o, 0 )).rgb * 2. +
texture(t0, tc + dt * vec2( 0, o )).rgb * 2. +
texture(t0, tc + dt * vec2( -o, 0 )).rgb * 2. +
texture(t0, tc + dt * vec2( 0, -o)).rgb * 2. +
texture(t0, tc + dt * vec2( o, o )).rgb * 1.5 +
texture(t0, tc + dt * vec2( o, -o)).rgb * 1.5 +
texture(t0, tc + dt * vec2( -o, -o )).rgb * 1.5 +
texture(t0, tc + dt * vec2( -o, o )).rgb * 1.5 +
texture(t0, tc + dt * vec2( o2, 0 )).rgb +
texture(t0, tc + dt * vec2( 0, o2)).rgb +
texture(t0, tc + dt * vec2(-o2, 0 )).rgb +
texture(t0, tc + dt * vec2( 0, -o2)).rgb/* +
texture(t0, tc + dt * vec2( o2, o )).rgb +
texture(t0, tc + dt * vec2( o2, -o)).rgb +
texture(t0, tc + dt * vec2(-o2, -o )).rgb +
texture(t0, tc + dt * vec2(-o2, o )).rgb +
texture(t0, tc + dt * vec2( o, o2)).rgb +
texture(t0, tc + dt * vec2( o, -o2)).rgb +
texture(t0, tc + dt * vec2( -o, -o2)).rgb +
texture(t0, tc + dt * vec2( -o, o2)).rgb*/) / 21.;
qgl_FragData[0] = vec4(scol, v0.w);
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}

View File

@@ -0,0 +1,15 @@
#version 150
uniform sampler2D t0, tg1, ts;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec4 v0 = texelFetch(t0, tc, 0), vg1 = texelFetch(tg1, tc, 0), vs = texelFetch(ts, tc, 0);
float rad;
float coeff = clamp(modf(v0.w, rad) * 1.1, 0., 1.);
float reflectivity = 0.;
float specularity = modf(vg1.w, reflectivity);
reflectivity = clamp(reflectivity / 100., 0., 1.);
qgl_FragData[0].rgb = mix(vs.rgb, v0.rgb, coeff * reflectivity);
//qgl_FragData[0].rgb = vec3(v0.w);
}

View File

@@ -0,0 +1,6 @@
#version 150
void main(void) {
qgl_FragTexture = qgl_Texture;
gl_Position = qgl_ftransform();
}