diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2015-05-17 19:18:04 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2015-05-17 19:18:04 +0300 |
commit | 4139686817501a4c22149b3ef8f9b4807f5053d6 (patch) | |
tree | 03f9cde1cfae612cec88e4a1cd386b4e407afff3 /source/blender/gpu/intern | |
parent | 3cff7768d5e919b60b42bac2182ff0efb130d720 (diff) |
Fix T44713: GLSL and BI inconsistency converting color to float node socket.
Diffstat (limited to 'source/blender/gpu/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index e92b58932a3..90e4ce69394 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -311,18 +311,16 @@ static void codegen_convert_datatype(DynStr *ds, int from, int to, const char *t BLI_dynstr_append(ds, name); } else if (to == GPU_FLOAT) { - if (from == GPU_VEC4) - BLI_dynstr_appendf(ds, "dot(%s.rgb, vec3(0.35, 0.45, 0.2))", name); - else if (from == GPU_VEC3) - BLI_dynstr_appendf(ds, "dot(%s, vec3(0.33))", name); + if (from == GPU_VEC4 || from == GPU_VEC3) + BLI_dynstr_appendf(ds, "(%s.r + %s.g + %s.b) / 3.0", name, name, name); else if (from == GPU_VEC2) BLI_dynstr_appendf(ds, "%s.r", name); } else if (to == GPU_VEC2) { if (from == GPU_VEC4) - BLI_dynstr_appendf(ds, "vec2(dot(%s.rgb, vec3(0.35, 0.45, 0.2)), %s.a)", name, name); + BLI_dynstr_appendf(ds, "vec2((%s.r + %s.g + %s.b) / 3.0, %s.a)", name, name, name, name); else if (from == GPU_VEC3) - BLI_dynstr_appendf(ds, "vec2(dot(%s.rgb, vec3(0.33)), 1.0)", name); + BLI_dynstr_appendf(ds, "vec2((%s.r + %s.g + %s.b) / 3.0, 1.0)", name, name, name); else if (from == GPU_FLOAT) BLI_dynstr_appendf(ds, "vec2(%s, 1.0)", name); } |