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:
authorOmarSquircleArt <omar.squircleart@gmail.com>2019-09-12 18:42:13 +0300
committerOmarSquircleArt <omar.squircleart@gmail.com>2019-09-12 18:42:13 +0300
commit2ea82e86ca60c1c268c6074ecba10524cebd97ed (patch)
treebf355c2a930f584685f68a833ce620ad15e63a70 /source/blender/gpu/intern/gpu_codegen.c
parentf80018b5f7497d7ed0fe79783c4cd76f05ec1c7c (diff)
Shading: Add Vertex Color node.
This patch adds a new Vertex Color node. The node also returns the alpha of the vertex color layer as an output. Reviewers: brecht Differential Revision: https://developer.blender.org/D5767
Diffstat (limited to 'source/blender/gpu/intern/gpu_codegen.c')
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 8b68bcd5889..242b0ed2e31 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -1080,6 +1080,15 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
"\treturn mix(c1, c2, step(vec3(0.04045), c));\n"
"}\n\n");
+ BLI_dynstr_append(ds,
+ "vec4 srgba_to_linear_attr(vec4 c) {\n"
+ "\tc = max(c, vec4(0.0));\n"
+ "\tvec4 c1 = c * (1.0 / 12.92);\n"
+ "\tvec4 c2 = pow((c + 0.055) * (1.0 / 1.055), vec4(2.4));\n"
+ "\tvec4 final = mix(c1, c2, step(vec4(0.04045), c));"
+ "\treturn vec4(final.xyz, c.a);\n"
+ "}\n\n");
+
/* Prototype because defined later. */
BLI_dynstr_append(ds,
"vec2 hair_get_customdata_vec2(const samplerBuffer);\n"
@@ -1184,7 +1193,7 @@ static char *code_generate_vertex(ListBase *nodes, const char *vert_code, bool u
}
else if (input->attr_type == CD_MCOL) {
BLI_dynstr_appendf(ds,
- "\tvar%d%s = srgb_to_linear_attr(att%d);\n",
+ "\tvar%d%s = srgba_to_linear_attr(att%d);\n",
input->attr_id,
use_geom ? "g" : "",
input->attr_id);