From 2ea82e86ca60c1c268c6074ecba10524cebd97ed Mon Sep 17 00:00:00 2001 From: OmarSquircleArt Date: Thu, 12 Sep 2019 17:42:13 +0200 Subject: 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 --- source/blender/gpu/intern/gpu_codegen.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source/blender/gpu/intern/gpu_codegen.c') 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); -- cgit v1.2.3