git-svn-id: svn://db.shs.com.ru/libs@702 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
@@ -95,6 +95,26 @@ void calcLight(in int index, in vec3 n, in vec3 v) {
|
||||
si += spot * spec * qgl_light_parameter[index].color.rgb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float GeometrySchlickGGX(float NdotV, float roughness) {
|
||||
float a = roughness;
|
||||
float k = (a * a) / 2.0;
|
||||
float nom = NdotV;
|
||||
float denom = NdotV * (1.0 - k) + k;
|
||||
return nom / denom;
|
||||
}
|
||||
// ----------------------------------------------------------------------------
|
||||
float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) {
|
||||
float NdotV = max(dot(N, V), 0.0);
|
||||
float NdotL = max(dot(N, L), 0.0);
|
||||
float ggx2 = GeometrySchlickGGX(NdotV, roughness);
|
||||
float ggx1 = GeometrySchlickGGX(NdotL, roughness);
|
||||
return ggx1 * ggx2;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void main(void) {
|
||||
ivec2 tc = ivec2(gl_FragCoord.xy);
|
||||
vec4 v1 = texelFetch(tex_1, tc, 0);
|
||||
@@ -118,11 +138,13 @@ void main(void) {
|
||||
float metalness = v2.r;
|
||||
float roughness = v2.g;
|
||||
float reflectivity = v2.b;
|
||||
float NdotV = dot(normal, v);
|
||||
float roughness3 = roughness*roughness*roughness;
|
||||
//bn = normalize(vec3(v3.w, v4.zw));
|
||||
//bn2 = normalize(cross(n, bn));
|
||||
rough_diff = max(roughness, _min_rough);
|
||||
rough_spec = max(roughness*roughness*roughness, _min_rough);
|
||||
float shlick = clamp(metalness + (1 - metalness) * pow(1 - dot(normal, v), 5), 0, 1);
|
||||
rough_spec = max(roughness3, _min_rough);
|
||||
float shlick = clamp(metalness + (1 - metalness) * pow(1 - NdotV, 5), 0, 1);
|
||||
|
||||
li = vec3(0.);//qgl_AmbientLight.color.rgb * qgl_AmbientLight.intensity;
|
||||
si = vec3(0.);
|
||||
@@ -131,7 +153,12 @@ void main(void) {
|
||||
si *= shlick;
|
||||
li *= (1 - shlick);
|
||||
alpha = min(1, alpha * (1 + shlick));
|
||||
|
||||
vec2 brdf = texture(tex_coeffs[0], vec2(NdotV*0.99, roughness3*0.995)).rg;
|
||||
float env_spec = shlick * brdf.x + brdf.y;
|
||||
|
||||
vec3 res_col = max(vec3(0), li * diffuse + si * mix(vec3(1), diffuse, metalness) + emission);
|
||||
res_col = mix(res_col, fog_color.rgb, env_spec);
|
||||
|
||||
float plen = length(pos.xyz);
|
||||
float fog = 1 - exp(-plen / fog_decay);
|
||||
@@ -140,6 +167,8 @@ void main(void) {
|
||||
|
||||
qgl_FragColor = vec4(res_col, alpha);
|
||||
|
||||
//qgl_FragColor.rgb = vec3(texture(tex_coeffs[0], qgl_FragTexture.xy).r);
|
||||
//qgl_FragColor.rgb = vec3(ldir);
|
||||
//vec3 specular = prefilteredColor * (F * envBRDF.x + envBRDF.y);
|
||||
//qgl_FragColor.rgb = vec3(shlick * brdf.x + brdf.y);
|
||||
//qgl_FragColor.rgb = vec3(env_spec);
|
||||
//qgl_FragColor.rgb = vec3(1-GeometrySchlickGGX(dot(normal, v),roughness));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user