[Bf-committers] what is the difference between these 2 LINEAR operations? or a bug?

oyster lepto.python at gmail.com
Sun Apr 12 14:03:34 CEST 2015


Hi,
These 2 operations in different sourcefile puzzled me. can anyone give
me any hints?
1. the 'color node_mix_linear(float t, color col1, color col2)'
function in https://developer.blender.org/diffusion/B/browse/master/intern/cycles/kernel/shaders/node_mix.osl,
says
[code]
    if (col2[0] > 0.5)
        outcol[0] = col1[0] + t * (2.0 * (col2[0] - 0.5));
    else
        outcol[0] = col1[0] + t * (2.0 * (col2[0]) - 1.0);
[/code]
if col2[0] > 0.5, then outcol[0] = col1[0] + t * (2.0 * (col2[0] -
0.5)) = col1[0] + t * (2.0 * col2[0] - 2.0 * 0.5) = col1[0] + t * (2.0
* col2[0] - 1.0 ). In other word, no matter what is col2[0], outcol[0]
is always col1[0] + t * (2.0 * (col2[0]) - 1.0). So, why do we need to
write 'else' since 'osl-languagespec.pdf' says color is made from 3
float.

2. in D:\blender-2.74-src\release\scripts\addons\uv_bake_texture_to_vcols.py,
we can find
[code]
              elif self.blendingMode == 'LINEAR_LIGHT':
                    if col_in[0] > 0.5:
                        col_result[0] = col_out[0] + 2.0 * (col_in[0] - 0.5)
                    else:
                        col_result[0] = col_out[0] + 2.0 * (col_in[0] - 1.0)
[/code]

So, I suppose that node_mix.osl is buggy, the correct code should be
[code]
    if (col2[0] > 0.5)
        outcol[0] = col1[0] + t * (2.0 * (col2[0] - 0.5));
    else
        outcol[0] = col1[0] + t * (2.0 * (col2[0] - 1.0));
[/code]

Am I right?


More information about the Bf-committers mailing list