diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-02 14:48:18 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-02 14:50:56 +0300 |
commit | 49247f0fc445ec014478d485883492a04ae5facb (patch) | |
tree | 81cdf5ce77232b5538542c43cf4d617e795937d8 /source/blender/gpu/intern/gpu_codegen.c | |
parent | be10d6d3f046cc628824c372dd5f96d17cc95dbc (diff) |
Fix T47207: Material shading incorrectly handles colorramp node
The issue was introduced by a fix for T44713 which only made GLSL
consistent with Cycles.
Now we do have conditional averaging or proper luma weighting based
on whether we're new old old shading system. Not totally ideal but
should work for until we re-design viewport possibly breaking how
Blender Internal does implicit conversion.
Diffstat (limited to 'source/blender/gpu/intern/gpu_codegen.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index c3f79bc9492..7cd05eff64e 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -318,7 +318,9 @@ 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 || from == GPU_VEC3) + if (from == GPU_VEC4) + BLI_dynstr_appendf(ds, "convert_rgba_to_float(%s)", name); + else if (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); @@ -1641,7 +1643,9 @@ static void gpu_nodes_prune(ListBase *nodes, GPUNodeLink *outlink) GPUPass *GPU_generate_pass( ListBase *nodes, GPUNodeLink *outlink, GPUVertexAttribs *attribs, int *builtins, - const GPUMatType type, const char *UNUSED(name), const bool use_opensubdiv) + const GPUMatType type, const char *UNUSED(name), + const bool use_opensubdiv, + const bool use_new_shading) { GPUShader *shader; GPUPass *pass; @@ -1664,6 +1668,14 @@ GPUPass *GPU_generate_pass( fragmentcode = code_generate_fragment(nodes, outlink->output); vertexcode = code_generate_vertex(nodes, type); geometrycode = code_generate_geometry(nodes, use_opensubdiv); + + int flags = GPU_SHADER_FLAGS_NONE; + if (use_opensubdiv) { + flags |= GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV; + } + if (use_new_shading) { + flags |= GPU_SHADER_FLAGS_NEW_SHADING; + } shader = GPU_shader_create_ex(vertexcode, fragmentcode, geometrycode, @@ -1672,8 +1684,7 @@ GPUPass *GPU_generate_pass( 0, 0, 0, - use_opensubdiv ? GPU_SHADER_FLAGS_SPECIAL_OPENSUBDIV - : GPU_SHADER_FLAGS_NONE); + flags); /* failed? */ if (!shader) { |