[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43991] trunk/blender/intern/cycles/kernel /svm/svm_brightness.h: Fix #30004: cycles brightness/contrast node issues.
Brecht Van Lommel
brechtvanlommel at pandora.be
Wed Feb 8 18:09:41 CET 2012
Revision: 43991
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43991
Author: blendix
Date: 2012-02-08 17:09:30 +0000 (Wed, 08 Feb 2012)
Log Message:
-----------
Fix #30004: cycles brightness/contrast node issues. The formula used did not work
very well for colors that can be outside of the 0.0..1.0 range, giving +/- infinity
results.
Now we just use a simple linear contrast factor as proposed by Paolo Sourvinos, and
clamp values to be >= 0, and also make the parameters work more in the 0..1 range
instead of the 0..100 range, to be more consistent with other nodes.
Modified Paths:
--------------
trunk/blender/intern/cycles/kernel/svm/svm_brightness.h
Modified: trunk/blender/intern/cycles/kernel/svm/svm_brightness.h
===================================================================
--- trunk/blender/intern/cycles/kernel/svm/svm_brightness.h 2012-02-08 16:48:26 UTC (rev 43990)
+++ trunk/blender/intern/cycles/kernel/svm/svm_brightness.h 2012-02-08 17:09:30 UTC (rev 43991)
@@ -27,29 +27,13 @@
float brightness = stack_load_float(stack, bright_offset);
float contrast = stack_load_float(stack, contrast_offset);
- brightness *= 1.0f/100.0f;
- float delta = contrast * (1.0f/200.0f);
- float a = 1.0f - delta * 2.0f;
- float b;
+ float a = 1.0f + contrast;
+ float b = brightness - contrast*0.5f;
- /*
- * The algorithm is by Werner D. Streidt
- * (http://visca.com/ffactory/archives/5-99/msg00021.html)
- * Extracted of OpenCV demhist.c
- */
- if (contrast > 0.0f) {
- a = (a > 0.0f? (1.0f / a): 0.0f);
- b = a * (brightness - delta);
- }
- else {
- delta *= -1.0f;
- b = a * (brightness + delta);
- }
+ color.x = max(a*color.x + b, 0.0f);
+ color.y = max(a*color.y + b, 0.0f);
+ color.z = max(a*color.z + b, 0.0f);
- color.x = a*color.x + b;
- color.y = a*color.y + b;
- color.z = a*color.z + b;
-
if (stack_valid(out_color))
stack_store_float3(stack, out_color, color);
}
More information about the Bf-blender-cvs
mailing list