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:
authorJeroen Bakker <j.bakker@atmind.nl>2019-04-16 15:00:16 +0300
committerJeroen Bakker <j.bakker@atmind.nl>2019-04-23 13:05:33 +0300
commitee701baff8caf6d184fa245e170c1e67981e2608 (patch)
tree0e84a0829141682cedfdf9770e755a3e9f833282 /source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
parentc9ed39925a51fc421a734027c2ef386157392f3b (diff)
Workbench: Support Active Vertex Color
Currently it is not possible to view the vertex colors of an object. To optimize the workflow, workbench will need to support Vertex Colors. The Vertex Colors is a new option in `shading->color_type`. When objects do not have vertex color, the objects will be rendered with the `V3D_SHADING_OBJECT_COLOR`. In order to support vertex colors in workbench the current texture/solid shading structure is migrated to a primary shaders and fallback shaders. Fix: T57000 Reviewers: brecht, fclem Differential Revision: https://developer.blender.org/D4694
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl')
-rw-r--r--source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl22
1 files changed, 22 insertions, 0 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
index dd737063f61..f2c684cdb6a 100644
--- a/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
+++ b/source/blender/draw/engines/workbench/shaders/workbench_prepass_vert.glsl
@@ -10,6 +10,9 @@ uniform mat3 NormalMatrix;
in vec3 pos;
in vec3 nor;
in vec2 u; /* active texture layer */
+# ifdef V3D_SHADING_VERTEX_COLOR
+in vec3 c; /* active color */
+# endif
# define uv u
#else /* HAIR_SHADER */
# ifdef V3D_SHADING_TEXTURE_COLOR
@@ -25,6 +28,9 @@ out vec3 normal_viewport;
#ifdef V3D_SHADING_TEXTURE_COLOR
out vec2 uv_interp;
#endif
+#ifdef V3D_SHADING_VERTEX_COLOR
+out vec3 vertexColor;
+#endif
/* From http://libnoise.sourceforge.net/noisegen/index.html */
float integer_noise(int n)
@@ -34,6 +40,16 @@ float integer_noise(int n)
return (float(nn) / 1073741824.0);
}
+#ifdef V3D_SHADING_VERTEX_COLOR
+vec3 srgb_to_linear_attr(vec3 c)
+{
+ c = max(c, vec3(0.0));
+ vec3 c1 = c * (1.0 / 12.92);
+ vec3 c2 = pow((c + 0.055) * (1.0 / 1.055), vec3(2.4));
+ return mix(c1, c2, step(vec3(0.04045), c));
+}
+#endif
+
void main()
{
#ifdef HAIR_SHADER
@@ -68,6 +84,12 @@ void main()
uv_interp = uv;
#endif
+#ifdef V3D_SHADING_VERTEX_COLOR
+# ifndef HAIR_SHADER
+ vertexColor = srgb_to_linear_attr(c);
+# endif
+#endif
+
#ifdef NORMAL_VIEWPORT_PASS_ENABLED
normal_viewport = NormalMatrix * nor;
# ifndef HAIR_SHADER