Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2017-07-03 16:07:14 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-07-03 16:18:46 +0300
commitd97c3bc7ad13cb9e3ec2248ce035a62c28ac70f8 (patch)
tree6dc5b6169e1398b4dc53f5aefc7304cb13ccbcda /source/blender/gpu/shaders
parent871325e26fe12efe8bf8a7042d94896f2f7faf6c (diff)
parenteb1532a86094ba5d59bf62b1fbd50f74a639d0a8 (diff)
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/gpu/shaders')
-rw-r--r--source/blender/gpu/shaders/gpu_shader_material.glsl14
1 files changed, 8 insertions, 6 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl
index 0c36d6ca618..1f9ab45e556 100644
--- a/source/blender/gpu/shaders/gpu_shader_material.glsl
+++ b/source/blender/gpu/shaders/gpu_shader_material.glsl
@@ -2690,7 +2690,7 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
/* ambient light */
// TODO: set ambient light to an appropriate value
- vec3 L = vec3(mix(0.1, 0.03, metallic)) * base_color.rgb;
+ vec3 L = mix(0.1, 0.03, metallic) * mix(base_color.rgb, subsurface_color.rgb, subsurface * (1.0 - metallic));
float eta = (2.0 / (1.0 - sqrt(0.08 * specular))) - 1.0;
@@ -2704,10 +2704,11 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
/* directional lights */
for (int i = 0; i < NUM_LIGHTS; i++) {
vec3 light_position_world = glLightSource[i].position.xyz;
- vec3 light_position = normalize(NormalMatrix * light_position_world);
+ vec3 light_position = normalize(light_position_world);
vec3 H = normalize(light_position + V);
+ vec3 light_diffuse = glLightSource[i].diffuse.rgb;
vec3 light_specular = glLightSource[i].specular.rgb;
float NdotL = dot(N, light_position);
@@ -2748,8 +2749,9 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
// sheen
vec3 Fsheen = schlick_fresnel(LdotH) * sheen * Csheen;
- diffuse_and_specular_bsdf = (M_1_PI * mix(Fd, ss, subsurface) * base_color.rgb + Fsheen)
- * (1.0 - metallic) + Gs * Fs * Ds;
+ vec3 diffuse_bsdf = (mix(Fd * base_color.rgb, ss * subsurface_color.rgb, subsurface) + Fsheen) * light_diffuse;
+ vec3 specular_bsdf = Gs * Fs * Ds * light_specular;
+ diffuse_and_specular_bsdf = diffuse_bsdf * (1.0 - metallic) + specular_bsdf;
}
diffuse_and_specular_bsdf *= max(NdotL, 0.0);
@@ -2766,11 +2768,11 @@ void node_bsdf_principled(vec4 base_color, float subsurface, vec3 subsurface_rad
float Fr = fresnel_dielectric_cos(LdotH, 1.5); //mix(0.04, 1.0, FH);
float Gr = smithG_GGX(CNdotL, 0.25) * smithG_GGX(CNdotV, 0.25);
- clearcoat_bsdf = clearcoat * Gr * Fr * Dr * vec3(0.25);
+ clearcoat_bsdf = clearcoat * Gr * Fr * Dr * vec3(0.25) * light_specular;
}
clearcoat_bsdf *= max(CNdotL, 0.0);
- L += light_specular * (diffuse_and_specular_bsdf + clearcoat_bsdf);
+ L += diffuse_and_specular_bsdf + clearcoat_bsdf;
}
result = vec4(L, 1.0);