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

This commit is contained in:
2019-12-03 14:24:40 +00:00
parent c38678056d
commit b1e1ad4aea
8 changed files with 54 additions and 43 deletions

View File

@@ -17,7 +17,6 @@ in vec3 view_dir;
uniform vec2 dt;
uniform float z_near;
uniform sampler2D tex_0, tex_1, tex_2, tex_3, tex_4;
uniform sampler2D tex_d, tex_sum;
uniform int lights_start, lights_count;
const vec3 luma = vec3(0.299, 0.587, 0.114);
@@ -33,6 +32,7 @@ void calcLight(in int index, in vec3 n, in vec3 v) {
ldir = lpos.xyz - (pos.xyz * lpos.w);
ldist = length(ldir);
ldir = normalize(ldir);
//ldir = vec3(0,0,1);
halfV = normalize(ldir + v);
NdotL = max(dot(n, ldir), 1E-6);
NdotH = max(dot(n, halfV), 1E-6);
@@ -90,32 +90,28 @@ void calcLight(in int index, in vec3 n, in vec3 v) {
void main(void) {
ivec2 tc = ivec2(gl_FragCoord.xy);
float z = texelFetch(tex_d, tc, 0).r;
vec4 v1 = texelFetch(tex_1, tc, 0);
float z = v1.w;
if (z == 1.) {
qgl_FragColor = vec4(0);
return;
}
vec4 v0 = texelFetch(tex_0, tc, 0),
v1 = texelFetch(tex_1, tc, 0),
v2 = texelFetch(tex_2, tc, 0),
v3 = texelFetch(tex_3, tc, 0),
v4 = texelFetch(tex_4, tc, 0);
z = z + z - 1;
z = ((_pe - 2.) * z_near) / (z + _pe - 1.); // infinite depth
pos.w = 1;
pos.xyz = view_dir * z;
vec3 v = normalize(-pos.xyz);
//vec2 sp = gl_FragCoord.xy * dt * 2 - vec2(1, 1);
vec3 diffuse = v0.rgb;
vec3 normal = v1.xyz;
vec3 specular = v2.rgb;
vec3 emission = v3.rgb;
float reflectivity = v0.w;
float roughness = v1.w;
float height = v2.w;
float roughness = v3.w;
//bn = normalize(vec3(v3.w, v4.zw));
//bn2 = normalize(cross(n, bn));
@@ -128,17 +124,6 @@ void main(void) {
for (int i = 0; i < lights_count; ++i)
calcLight(lights_start + i, normal, v);
vec4 result = vec4(max(vec3(0), li * diffuse + si * specular + emission), 1);
#ifndef FIRST_PASS
result += texelFetch(tex_sum, tc, 0);
#endif
qgl_FragColor = result;
//qgl_FragColor.rgb = vec3(1);
//qgl_FragData[4] = vec4(speed.xy, bn.yz);
//ivec2 itc = ivec2(gl_FragCoord.xy);
//qgl_FragData[0].rgb = vec3(dot(n,vec3(0,0,1)));
//qgl_FragData[0].rgb = diffuse.rgb * dot(n,vec3(0,0,1));
qgl_FragColor = vec4(max(vec3(0), li * diffuse + si * specular + emission), 1);
//qgl_FragColor.rgb = vec3(pos.xyz/100);
}