Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSv. Lockal <lockalsash@gmail.com>2015-05-05 09:11:54 +0300
committerSv. Lockal <lockalsash@gmail.com>2015-05-05 09:11:54 +0300
commit7201f6d14c0161ad9a0d4143d1c5caf872e0d93e (patch)
treecf3d0b69ed4a1ad54a42c4c9322df396ab3e2a0e /intern/cycles/render/nodes.cpp
parent22bbd1c51219aafb40adb3e9a206f660a621fd70 (diff)
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
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r--intern/cycles/render/nodes.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 8529855ff2e..d17d531aa77 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -3652,9 +3652,17 @@ void BlackbodyNode::compile(SVMCompiler& compiler)
ShaderInput *temperature_in = input("Temperature");
ShaderOutput *color_out = output("Color");
- compiler.stack_assign(temperature_in);
compiler.stack_assign(color_out);
- compiler.add_node(NODE_BLACKBODY, temperature_in->stack_offset, color_out->stack_offset);
+
+ if(temperature_in->link == NULL) {
+ float3 color = svm_math_blackbody_color(temperature_in->value.x);
+ compiler.add_node(NODE_VALUE_V, color_out->stack_offset);
+ compiler.add_node(NODE_VALUE_V, color);
+ }
+ else {
+ compiler.stack_assign(temperature_in);
+ compiler.add_node(NODE_BLACKBODY, temperature_in->stack_offset, color_out->stack_offset);
+ }
}
void BlackbodyNode::compile(OSLCompiler& compiler)