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

This commit is contained in:
2019-12-10 18:01:17 +00:00
parent ff4f9a3b2b
commit 16146ae6fd
4 changed files with 20 additions and 14 deletions

View File

@@ -7,12 +7,16 @@ void main(void) {
// frag //
uniform sampler2D tex_0, tex_1, tex_2, tex_3, tex_4;
uniform sampler2D tex_s_0, tex_s_1, tex_t_0, tex_t_1;
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
vec4 v0 = texelFetch(tex_0, tc, 0);
vec4 v1 = texelFetch(tex_1, tc, 0);
vec3 res = v0.rgb + v1.rgb;
qgl_FragColor.rgb = res;
vec4 vs0 = texelFetch(tex_s_0, tc, 0);
vec4 vs1 = texelFetch(tex_s_1, tc, 0);
vec3 sr = vs0.rgb + vs1.rgb;
vec4 vt0 = texelFetch(tex_t_0, tc, 0);
vec4 vt1 = texelFetch(tex_t_1, tc, 0);
vec3 tr = vt0.rgb + vt1.rgb;
float alpha = (vt0.a + vt1.a) / 2;
qgl_FragColor.rgb = mix(sr, tr, alpha);
}

View File

@@ -32,6 +32,7 @@ void main(void) {
vec2 tc = qgl_FragTexture.xy;
vec4 diffuse = qgl_materialTexture(QGL_MAP_DIFFUSE, tc, vec4(0)) * qgl_material[qgl_MaterialIndex].color_diffuse * object_color;
diffuse.a *= (1.f - qgl_material[qgl_MaterialIndex].transparency);
vec3 normal, dn;
dn = qgl_materialTexture(QGL_MAP_NORMAL, tc, -vec4(0.5, 0.5, 1., 0.)).xyz;
@@ -57,9 +58,9 @@ void main(void) {
z = z + z - 1;
z = ((_pe - 2.) * z_near) / (z + _pe - 1.); // infinite depth
qgl_FragData[0] = vec4(diffuse .rgb, reflectivity);
qgl_FragData[0] = vec4(diffuse .rgba);
qgl_FragData[1] = vec4(normal .xyz, z);
qgl_FragData[2] = vec4(specular.rgb, height );
qgl_FragData[2] = vec4(specular.rgb, reflectivity);
qgl_FragData[3] = vec4(emission.rgb, roughness/*bn.x*/);
//qgl_FragData[4] = vec4(speed.xy, bn.yz);

View File

@@ -109,10 +109,11 @@ void main(void) {
vec3 normal = v1.xyz;
vec3 specular = v2.rgb;
vec3 emission = v3.rgb;
float reflectivity = v0.w;
float height = v2.w;
float reflectivity = v2.w;
//float height = v2.w;
float roughness = v3.w;
//bn = normalize(vec3(v3.w, v4.zw));
float alpha = v0.a;
//bn = normalize(vec3(v3.w, v4.zw));
//bn2 = normalize(cross(n, bn));
shm_diff = max(roughness, 0.00001);
@@ -124,6 +125,6 @@ void main(void) {
for (int i = 0; i < lights_count; ++i)
calcLight(lights_start + i, normal, v);
qgl_FragColor = vec4(max(vec3(0), li * diffuse + si * specular + emission), 1);
//qgl_FragColor.rgb = vec3(pos.xyz/100);
qgl_FragColor = vec4(max(vec3(0), li * diffuse + si * specular + emission), alpha);
//qgl_FragColor. = vec3(alpha);
}

View File

@@ -8,7 +8,7 @@ void main(void) {
// frag //
uniform sampler2D tex_0;
uniform float exposure, frame_max;
uniform float gamma, frame_max;
const vec3 luma = vec3(0.299, 0.587, 0.114);
@@ -17,7 +17,7 @@ void main(void) {
vec4 src = texelFetch(tex_0, tc, 0);
vec3 res = src.rgb;
float l = dot(res, luma) * 0.75;
float g = exposure / frame_max;
float g = gamma / frame_max;
res /= l;
l = 1 - exp(-l*g);
qgl_FragColor.rgb = res * l;