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

This commit is contained in:
2015-11-26 11:53:29 +00:00
parent 2ace72ff47
commit 4cbcbb5174
26 changed files with 346 additions and 105 deletions

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

@@ -15,11 +15,11 @@ void main(void) {
float z = pos.w;//((z_near / (z_near-z_far)) * z_far) / (pos.w - (z_far / (z_far-z_near)));
vec4 dc = qgl_FragColor;
vec2 tc = qgl_FragTexture.xy;
float hei = dot(texture2D(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
float hei = dot(texture(qgl_Material.map_relief.map, tc).rgb, luma) * qgl_Material.map_relief.amount + qgl_Material.map_relief.offset;
//if (acc_fog) dc.xyz = mix(dc.rgb, gl_Fog.color.rgb, fogCoord);
vec3 n, dn;
dn = (texture2D(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.)) * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
dn = (texture(qgl_Material.map_normal.map, tc).rgb - vec3(0.5, 0.5, 1.)) * qgl_Material.map_normal.amount + qgl_Material.map_normal.offset;
//float tx = dn.x;
dn.y = -dn.y;
//dn.y = tx;
@@ -34,12 +34,12 @@ void main(void) {
dpm = dpm * gl_ModelViewProjectionMatrixInverse;
dpm += */
//tc += 1+et.xy * hei/10;// / et.z;
dc *= texture2D(qgl_Material.map_diffuse.map, tc) * qgl_Material.map_diffuse.amount + qgl_Material.map_diffuse.offset;
dc *= texture(qgl_Material.map_diffuse.map, tc) * qgl_Material.map_diffuse.amount + qgl_Material.map_diffuse.offset;
vec4 spec = texture2D(qgl_Material.map_specular.map, tc) * qgl_Material.map_specular.amount + qgl_Material.map_specular.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;
vec4 specularity = texture2D(qgl_Material.map_specularity.map, tc) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
vec4 self = texture2D(qgl_Material.map_self_illumination.map, tc) * qgl_Material.map_self_illumination.amount + qgl_Material.map_self_illumination.offset;
vec4 specularity = texture(qgl_Material.map_specularity.map, tc) * qgl_Material.map_specularity.amount + qgl_Material.map_specularity.offset;
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;
qgl_FragData[0] = vec4(dc.rgb, z);

View File

@@ -25,5 +25,6 @@ void main(void) {
//tp /= tp.w;
src_normal = normalize(vec3(pos.xy * dt * 2., 0));
pos.w = tp.w;
//pos *= pos.w;
gl_Position = tp;//ftransform();
}

View File

@@ -30,11 +30,13 @@ void calcLight(in int index, in vec3 n, in vec3 v, in vec4 v2) {
NdotH = max(dot(n, halfV), 0.);
spot = step(0., NdotL) * qgl_Light[index].intensity;
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));
}*/
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 = clamp(scos / (-qgl_Light[index].endAngleCos + qgl_Light[index].startAngleCos + 0.0001),0,1);
spot *= smoothstep(qgl_Light[index].endAngleCos, qgl_Light[index].startAngleCos, scos);
//spot = pow(spot, (qgl_Light[index].spotExponent + 0.001));
}
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);
@@ -72,6 +74,7 @@ void main(void) {
pos.xy *= v3.w;
pos.z = posz;
pos.xyz += n * height;
//pos.xyz = v3.xyz;
//pos = v3;
//pos = vec4(sp, 0, 1.) * mat_proji;
//pos *= v0.w;
@@ -79,37 +82,15 @@ void main(void) {
//pos.xy *= 10.;
//pos.z = v0.w;
vec3 v = normalize(-pos.xyz);
sh_pow = 1. / max((1. - v1.w), 0.0001);
sh_mul = max(1. - v1.w, 0.0001);
//for (int i = 0; i < 16; ++i)
calcLight(7, n, v, v2);
/*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);
}
}
}
}
}
}
}
}*/
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texture2D(t_pp, tc).rgb;
for (int i = 0; i < 16; ++i)
calcLight(i, n, v, v2);
qgl_FragData[0].rgb = li * dc + si * v2.rgb + v3.rgb + texture(t_pp, tc).rgb;
//qgl_FragData[0].rgb = vec3(abs(lpos.xyz - pos.xyz)/10);
//qgl_FragData[0].rgb = texture2D(t_pp, tc).rgb;
//qgl_FragData[0].rgb = vec3(pow(NdotH,100)*2);
//qgl_FragData[0].rgb = si.rgb;
//qgl_FragData[0].rgb = (v0.rgb)/2;
//qgl_FragData[0].a = 0.;
}

27
qglview/shaders/hdr.frag Normal file
View File

@@ -0,0 +1,27 @@
#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) {
vec3 inColor = texture(t0, qgl_FragTexture.xy).rgb;
inColor *= exposure;
float ExposureBias = 1;
vec3 curr = Uncharted2Tonemap(ExposureBias*inColor);
vec3 whiteScale = 1 / Uncharted2Tonemap(vec3(tW));
vec3 color = curr * whiteScale;
vec3 retColor = pow(color, vec3(1 / 2.2));
qgl_FragData[0].rgb = retColor;
}

6
qglview/shaders/hdr.vert Normal file
View File

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