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>2020-03-11 19:07:43 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-03-11 19:12:16 +0300
commitc476c36e400883d929a7149def8dcb6ad6157a86 (patch)
treec19c43ad1ed82f333c08bee7d2096024fed812dd /source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
parentf01bc597a8e6bf5df19f1af0c422918c96b25e41 (diff)
Workbench Simplification Refactor
This patch is (almost) a complete rewrite of workbench engine. The features remain unchanged but the code quality is greatly improved. Hair shading is brighter but also more correct. This also introduce the concept of `DRWShaderLibrary` to make a simple include system inside the GLSL files. Differential Revision: https://developer.blender.org/D7060
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl44
1 files changed, 44 insertions, 0 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl b/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
new file mode 100644
index 00000000000..cdb9823096c
--- /dev/null
+++ b/source/blender/draw/engines/workbench/shaders/workbench_composite_frag.glsl
@@ -0,0 +1,44 @@
+
+#pragma BLENDER_REQUIRE(common_view_lib.glsl)
+#pragma BLENDER_REQUIRE(workbench_common_lib.glsl)
+#pragma BLENDER_REQUIRE(workbench_matcap_lib.glsl)
+#pragma BLENDER_REQUIRE(workbench_world_light_lib.glsl)
+
+uniform sampler2D materialBuffer;
+uniform sampler2D normalBuffer;
+
+in vec4 uvcoordsvar;
+
+out vec4 fragColor;
+
+void main()
+{
+ /* Normal and Incident vector are in viewspace. Lighting is evaluated in viewspace. */
+ vec3 I = view_vector_from_screen_uv(uvcoordsvar.st, world_data.viewvecs, ProjectionMatrix);
+ vec3 N = workbench_normal_decode(texture(normalBuffer, uvcoordsvar.st));
+ vec4 mat_data = texture(materialBuffer, uvcoordsvar.st);
+
+ vec3 base_color = mat_data.rgb;
+
+ float roughness, metallic;
+ workbench_float_pair_decode(mat_data.a, roughness, metallic);
+
+#ifdef V3D_LIGHTING_MATCAP
+ /* When using matcaps, mat_data.a is the backface sign. */
+ N = (mat_data.a > 0.0) ? N : -N;
+
+ fragColor.rgb = get_matcap_lighting(base_color, N, I);
+#endif
+
+#ifdef V3D_LIGHTING_STUDIO
+ fragColor.rgb = get_world_lighting(base_color, roughness, metallic, N, I);
+#endif
+
+#ifdef V3D_LIGHTING_FLAT
+ fragColor.rgb = base_color;
+#endif
+
+ fragColor.rgb *= get_shadow(N);
+
+ fragColor.a = 1.0;
+}