diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2017-07-06 14:31:36 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2017-07-06 14:32:19 +0300 |
commit | e5462421c006929f4e88b27d38b3391d05163262 (patch) | |
tree | e2a29067d10faf30555adcc322466b99e6a63c5d /source/blender/gpu | |
parent | a69e3c9ee16241068797b2852504441bfe3d5ca2 (diff) |
Eevee: Add support for common BSDFs.
Add Diffuse BSDF, and Glossy.
Also Use World normal instead of view normal as input.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/shaders/gpu_shader_material.glsl | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index 7c320253cd3..e9f7fb338c9 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -2661,6 +2661,9 @@ layout(std140) uniform lightSource { /* bsdfs */ void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out Closure result) { +#ifdef EEVEE_ENGINE + vec3 L = eevee_surface_diffuse_lit(N, vec3(1.0), 1.0); +#else /* ambient light */ vec3 L = vec3(0.2); @@ -2672,15 +2675,21 @@ void node_bsdf_diffuse(vec4 color, float roughness, vec3 N, out Closure result) float bsdf = max(dot(N, light_position), 0.0); L += light_diffuse * bsdf; } +#endif result = Closure(L * color.rgb, 1.0); } void node_bsdf_glossy(vec4 color, float roughness, vec3 N, out Closure result) { +#ifdef EEVEE_ENGINE + vec3 L = eevee_surface_glossy_lit(N, vec3(1.0), roughness, 1.0); +#else /* ambient light */ vec3 L = vec3(0.2); + direction_transform_m4v3(N, ViewMatrix, N); + /* directional lights */ for (int i = 0; i < NUM_LIGHTS; i++) { vec3 light_position = glLightSource[i].position.xyz; @@ -2693,6 +2702,7 @@ void node_bsdf_glossy(vec4 color, float roughness, vec3 N, out Closure result) bsdf += 0.5 * max(dot(N, light_position), 0.0); L += light_specular * bsdf; } +#endif result = Closure(L * color.rgb, 1.0); } |