Page MenuHome

GLSL - color conversion from RGB to Value uses unweighted average (like vector conversion)
Closed, ArchivedPublic

Description

System Information
windows, gtx980

Blender Version
2.75
Worked: (optional)
2.74

Short description of error
When a node with float input (like a math node) is connected to a color, the color was converted using a weighted average based on human perception:

f = dot(col, vec3(0.35, 0.45, 0.2)) until 2.74,

Now, it's

(col.r, col.g, col.b) / 3.0

no matter if a vector or color is connected to the float input.

Exact steps for others to reproduce the error

Attached blend file: export a shader in 2.74 and 2.75, (gpu.export_shader) and diff them
In 2.74, the add node function is clalled by sth like

math_add(dot(tmp2.rgb, vec3(0.35, 0.45, 0.2)), dot(tmp4.rgb, vec3(0.35, 0.45, 0.2)), tmp7);

in 2.75, it's

math_add((tmp2.r + tmp2.g + tmp2.b) / 3.0, (tmp4.r + tmp4.g + tmp4.b) / 3.0, tmp7);

Event Timeline

Michael Otto (mayqel) raised the priority of this task from to 90.
Michael Otto (mayqel) updated the task description. (Show Details)
Michael Otto (mayqel) edited a custom field.
Kévin Dietrich (kevindietrich) changed the task status from Unknown Status to Archived.Aug 5 2015, 3:31 AM

This is not a bug, rather, it's a fix. There was an inconsistency between how Blender internal render engine and GLSL handled color to float socket conversion, which was eventually fixed by rB4139686817501a4c22149b3ef8f9b4807f5053d6. Doing a weighting based on human perception should be carefully handled by the color management pipeline and has nothing to do with such conversion.

Thanks for the report, but again this is not bug.

Makes sense. Thank you for looking into it!