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

This commit is contained in:
2019-12-12 16:55:17 +00:00
parent 52153469a9
commit af250891cc

View File

@@ -23,7 +23,7 @@ uniform vec4 fog_color = vec4(0.5, 0.5, 0.5, 1);
uniform float fog_decay = 10, fog_density = 0;
const vec3 luma = vec3(0.299, 0.587, 0.114);
const float _pe = 2.4e-7;
const float _pe = 2.4e-7, _min_rough = 1.e-8;
vec4 pos, lpos, shp;
vec3 li, si, ldir, halfV, bn, bn2, lwdir;
@@ -37,13 +37,13 @@ void calcLight(in int index, in vec3 n, in vec3 v) {
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);
spot = step(1.001E-6, NdotL) * qgl_light_parameter[index].intensity;
NdotL = max(dot(n, ldir), 1E-8);
NdotH = max(dot(n, halfV), 1E-8);
spot = step(1.001E-8, NdotL) * qgl_light_parameter[index].decay_intensity.w;
#ifdef SPOT
float scos = max(dot(-ldir, qgl_light_position[index].direction.xyz), 0.);
spot *= scos * step(qgl_light_parameter[index].endAngleCos, scos);
spot *= smoothstep(qgl_light_parameter[index].endAngleCos, qgl_light_parameter[index].startAngleCos, scos);
spot *= scos * step(qgl_light_parameter[index].angles.w, scos);
spot *= smoothstep(qgl_light_parameter[index].angles.w, qgl_light_parameter[index].angles.y, scos);
/*//lwdir = mat3(mat_viewi) * qgl_Light[index].direction.xyz;
//bn = normalize(cross(lwdir, vec3(1, 0, 0)));
//bn2 = normalize(cross(lwdir, bn));
@@ -75,9 +75,8 @@ void calcLight(in int index, in vec3 n, in vec3 v) {
//shadow += shadow += getShadow(index, pos.xyz, vds+vds2)*10;
spot *= mix(1., shadow / 11., shadow_on);*/
#endif
spot /= (qgl_light_parameter[index].constantAttenuation +
ldist * (qgl_light_parameter[index].linearAttenuation +
ldist * qgl_light_parameter[index].quadraticAttenuation));
vec3 dist_decay = vec3(1, ldist, ldist*ldist);
spot /= dot(qgl_light_parameter[index].decay_intensity.xyz, dist_decay);
float NdotLs = NdotL*NdotL;
float NdotHs = NdotH*NdotH;
@@ -99,29 +98,28 @@ void main(void) {
qgl_FragColor = vec4(fog_color.rgb, 0);
return;
}
pos.w = 1;
pos.xyz = view_dir * z;
vec3 v = normalize(-pos.xyz);
vec4 v0 = texelFetch(tex_0, tc, 0),
v2 = texelFetch(tex_2, tc, 0),
v3 = texelFetch(tex_3, tc, 0),
v4 = texelFetch(tex_4, tc, 0);
pos.w = 1;
pos.xyz = view_dir * z;
vec3 v = normalize(-pos.xyz);
vec3 diffuse = v0.rgb;
vec3 normal = v1.xyz;
vec3 specular = v2.rgb;
vec3 emission = v3.rgb;
float reflectivity = v2.w;
//float height = v2.w;
float roughness = v3.w;
float alpha = v0.a;
float reflectivity = v2.w;
float roughness = v3.w;
//bn = normalize(vec3(v3.w, v4.zw));
//bn2 = normalize(cross(n, bn));
roughness = max(roughness, _min_rough);
shm_diff = max(roughness, 0.00001);
roughness = roughness*roughness*roughness;
shm_spec = max(roughness, 0.00001);
shm_diff = roughness;
shm_spec = max(roughness*roughness*roughness, _min_rough);
//sh_pow = 1. / max(roughness, 0.00001);
li = vec3(0.);//qgl_AmbientLight.color.rgb * qgl_AmbientLight.intensity;
si = vec3(0.);
@@ -135,5 +133,5 @@ void main(void) {
res_col = mix(res_col, fog_color.rgb, fog);
qgl_FragColor = vec4(res_col, alpha);
//qgl_FragColor.rgb = vec3(fog);
//qgl_FragColor.rgb = vec3(normal);
}