Cycles: Use curve approximation for blackbody instead of lookup table

Now we calculate color in range 800..12000 using an approximation a/x+bx+c for R and G and ((at + b)t + c)t + d) for B.
Max absolute error for RGB for non-lut function is less than 0.0001, which is enough to get the same 8 bit/channel color as for OSL with a noticeable performance difference.
However there is a slight visible difference between previous non-OSL implementation because of lookup table interpolation and offset-by-one mistake.
The previous implementation gave black color outside of soft range (t > 12000), now it gives the same color as for 12000.

Also blackbody node without input connected is being converted to value input at shader compile time.

Reviewers: dingto, sergey

Reviewed By: dingto

Subscribers: nutel, brecht, juicyfruit

Differential Revision: https://developer.blender.org/D1280
This commit is contained in:
Sv. Lockal
2015-05-05 06:11:54 +00:00
parent 22bbd1c512
commit 7201f6d14c
13 changed files with 76 additions and 258 deletions

View File

@@ -393,10 +393,6 @@ void SVMCompiler::generate_node(ShaderNode *node, set<ShaderNode*>& done)
current_shader->has_heterogeneous_volume = true;
}
/* detect if we have a blackbody converter, to prepare lookup table */
if(node->has_converter_blackbody())
current_shader->has_converter_blackbody = true;
if(node->has_object_dependency()) {
current_shader->has_object_dependency = true;
}
@@ -716,7 +712,6 @@ void SVMCompiler::compile(Shader *shader, vector<int4>& global_svm_nodes, int in
shader->has_surface_transparent = false;
shader->has_surface_bssrdf = false;
shader->has_bssrdf_bump = false;
shader->has_converter_blackbody = false;
shader->has_volume = false;
shader->has_displacement = false;
shader->has_heterogeneous_volume = false;