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:
authorClément Foucault <foucault.clem@gmail.com>2018-11-28 17:57:40 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-11-28 17:59:56 +0300
commit2d720f51cd786f3e0924602efb6ec89ef8ed077f (patch)
tree3b1ac1223a1c35e17e5085f99ef231273c801526 /source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
parent52458ab49d40081466e369709d68c13a6a47663e (diff)
Workbench: Change Studio lighting
This is in order to have more flexible ligthing presets in the future. The diffuse lighting from hdris was nice but lacked the corresponding specular information. This is an attempt to make it possible to customize the lighting and have a cheap/easy/nice-looking pseudo-PBR workflow. * Add cheap PBR to Workbench with fresnel and better roughness support. This improves the look of the metallic surfaces and is easier to control. * Add ambient light to studio lights settings: just a constant color added to the shading. * Add Smooth option to studio lights settings: This option fakes the effect of making the light bigger making the lighting smoother for this light. Smoother lights gets reflected like a background hdri. * Change default light settings to include the smooth params. * Remove specular highlights from flat shading. (could be added back but how do we make it good looking?) * If specular lighting is disabled, use base color without using metallic. * Include a lot of code simplification/cleanup/confusion fix.
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl57
1 files changed, 22 insertions, 35 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
index f15e6b613a9..4aa471f70d8 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_deferred_composite_frag.glsl
@@ -1,6 +1,7 @@
out vec4 fragColor;
uniform mat4 ProjectionMatrix;
+uniform mat4 ViewMatrixInverse;
uniform usampler2D objectId;
uniform sampler2D colorBuffer;
@@ -14,7 +15,6 @@ uniform vec4 viewvecs[3];
uniform float shadowMultiplier;
uniform float lightMultiplier;
uniform float shadowShift = 0.1;
-uniform mat3 normalWorldMatrix;
#ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
uniform sampler2D matcapImage;
@@ -70,39 +70,30 @@ void main()
vec3 I_vs = view_vector_from_screen_uv(uv_viewport, viewvecs, ProjectionMatrix);
-#ifdef STUDIOLIGHT_ORIENTATION_VIEWNORMAL
- bool flipped = world_data.matcap_orientation != 0;
- vec2 matcap_uv = matcap_uv_compute(I_vs, normal_viewport, flipped);
- diffuse_color = textureLod(matcapImage, matcap_uv, 0.0);
-#endif
-
-#ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
- vec4 specular_data = texelFetch(specularBuffer, texel, 0);
- vec3 specular_color = get_world_specular_lights(world_data, specular_data, normal_viewport, I_vs);
-#else
- vec3 specular_color = vec3(0.0);
-#endif
-
+ /* -------- SHADING --------- */
#ifdef V3D_LIGHTING_FLAT
- vec3 diffuse_light = vec3(1.0);
-#endif
+ vec3 shaded_color = diffuse_color.rgb;
-#ifdef V3D_LIGHTING_MATCAP
- vec3 diffuse_light = texelFetch(specularBuffer, texel, 0).rgb;
-#endif
+#elif defined(V3D_LIGHTING_MATCAP)
+ bool flipped = world_data.matcap_orientation != 0;
+ vec2 matcap_uv = matcap_uv_compute(I_vs, normal_viewport, flipped);
+ vec3 object_color = texelFetch(specularBuffer, texel, 0).rgb;
+ vec3 matcap = textureLod(matcapImage, matcap_uv, 0.0).rgb;
+ vec3 shaded_color = matcap * object_color;
-#ifdef V3D_LIGHTING_STUDIO
-# ifdef STUDIOLIGHT_ORIENTATION_CAMERA
- vec3 diffuse_light = get_camera_diffuse_light(world_data, normal_viewport);
-# endif
+#elif defined(V3D_LIGHTING_STUDIO)
-# ifdef STUDIOLIGHT_ORIENTATION_WORLD
- vec3 normal_world = normalWorldMatrix * normal_viewport;
- vec3 diffuse_light = get_world_diffuse_light(world_data, normal_world);
+# ifdef V3D_SHADING_SPECULAR_HIGHLIGHT
+ vec4 specular_data = texelFetch(specularBuffer, texel, 0);
+# else
+ vec4 specular_data = vec4(0.0);
# endif
+ vec3 shaded_color = get_world_lighting(world_data,
+ diffuse_color.rgb, specular_data.rgb, specular_data.a,
+ normal_viewport, I_vs);
#endif
- vec3 shaded_color = diffuse_light * diffuse_color.rgb + specular_color;
+ /* -------- POST EFFECTS --------- */
#ifdef V3D_SHADING_SSAO
vec2 cavity = texelFetch(cavityBuffer, texel, 0).rg;
shaded_color *= 1.0 - cavity.x;
@@ -119,16 +110,12 @@ void main()
/* The step function might be ok for meshes but it's
* clearly not the case for hairs. Do smoothstep in this case. */
float shadow_mix = smoothstep(1.0, shadowShift, light_factor);
- float light_multiplier = mix(lightMultiplier, shadowMultiplier, shadow_mix);
-
-#else /* V3D_SHADING_SHADOW */
- float light_multiplier = 1.0;
-#endif /* V3D_SHADING_SHADOW */
-
- shaded_color *= light_multiplier;
+ shaded_color *= mix(lightMultiplier, shadowMultiplier, shadow_mix);
+#endif
#ifdef V3D_SHADING_OBJECT_OUTLINE
shaded_color = mix(world_data.object_outline_color.rgb, shaded_color, object_outline);
-#endif /* V3D_SHADING_OBJECT_OUTLINE */
+#endif
+
fragColor = vec4(shaded_color, 1.0);
}