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:
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader_material.glsl')
-rw-r--r--source/blender/gpu/intern/gpu_shader_material.glsl22
1 files changed, 14 insertions, 8 deletions
diff --git a/source/blender/gpu/intern/gpu_shader_material.glsl b/source/blender/gpu/intern/gpu_shader_material.glsl
index 4a9d793aaad..5aaf99bdd24 100644
--- a/source/blender/gpu/intern/gpu_shader_material.glsl
+++ b/source/blender/gpu/intern/gpu_shader_material.glsl
@@ -122,7 +122,7 @@ void uv_attribute(vec2 attuv, out vec3 uv)
uv = vec3(attuv*2.0 - vec2(1.0, 1.0), 0.0);
}
-void geom(vec3 co, vec3 nor, mat4 viewinvmat, vec3 attorco, vec2 attuv, vec4 attvcol, out vec3 global, out vec3 local, out vec3 view, out vec3 orco, out vec3 uv, out vec3 normal, out vec4 vcol, out float frontback)
+void geom(vec3 co, vec3 nor, mat4 viewinvmat, vec3 attorco, vec2 attuv, vec4 attvcol, out vec3 global, out vec3 local, out vec3 view, out vec3 orco, out vec3 uv, out vec3 normal, out vec4 vcol, out float vcol_alpha, out float frontback)
{
local = co;
view = normalize(local);
@@ -131,6 +131,7 @@ void geom(vec3 co, vec3 nor, mat4 viewinvmat, vec3 attorco, vec2 attuv, vec4 att
uv_attribute(attuv, uv);
normal = -normalize(nor); /* blender render normal is negated */
vcol_attribute(attvcol, vcol);
+ vcol_alpha = attvcol.a;
frontback = 1.0;
}
@@ -1836,7 +1837,7 @@ float hypot(float x, float y)
/* bsdfs */
-void node_bsdf_diffuse(vec4 color, vec3 N, out vec4 result)
+void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out vec4 result)
{
/* ambient light */
vec3 L = vec3(0.2);
@@ -1855,14 +1856,19 @@ void node_bsdf_diffuse(vec4 color, vec3 N, out vec4 result)
void node_bsdf_glossy(vec4 color, float roughness, vec3 N, vec3 I, out vec4 result)
{
- vec3 L = vec3(0.0);
+ /* ambient light */
+ vec3 L = vec3(0.2);
/* directional lights */
for(int i = 0; i < NUM_LIGHTS; i++) {
+ vec3 light_position = gl_LightSource[i].position.xyz;
vec3 H = gl_LightSource[i].halfVector.xyz;
+ vec3 light_diffuse = gl_LightSource[i].diffuse.rgb;
vec3 light_specular = gl_LightSource[i].specular.rgb;
- float bsdf = pow(max(dot(N, H), 0.0), 1.0/roughness);
+ /* we mix in some diffuse so low roughness still shows up */
+ float bsdf = 0.5*pow(max(dot(N, H), 0.0), 1.0/roughness);
+ bsdf += 0.5*max(dot(N, light_position), 0.0);
L += light_specular*bsdf;
}
@@ -1871,17 +1877,17 @@ void node_bsdf_glossy(vec4 color, float roughness, vec3 N, vec3 I, out vec4 resu
void node_bsdf_anisotropic(vec4 color, float roughnessU, float roughnessV, vec3 N, vec3 I, out vec4 result)
{
- node_bsdf_diffuse(color, N, result);
+ node_bsdf_diffuse(color, 0.0, N, result);
}
void node_bsdf_glass(vec4 color, float roughness, float ior, vec3 N, vec3 I, out vec4 result)
{
- node_bsdf_diffuse(color, N, result);
+ node_bsdf_diffuse(color, 0.0, N, result);
}
void node_bsdf_translucent(vec4 color, vec3 N, out vec4 result)
{
- node_bsdf_diffuse(color, N, result);
+ node_bsdf_diffuse(color, 0.0, N, result);
}
void node_bsdf_transparent(vec4 color, out vec4 result)
@@ -1895,7 +1901,7 @@ void node_bsdf_transparent(vec4 color, out vec4 result)
void node_bsdf_velvet(vec4 color, float sigma, vec3 N, out vec4 result)
{
- node_bsdf_diffuse(color, N, result);
+ node_bsdf_diffuse(color, 0.0, N, result);
}
/* emission */