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
path: root/intern
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-02-08 21:09:30 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-02-08 21:09:30 +0400
commitb6d12f11fedd9544429745c13381d36ed6d20e8c (patch)
tree3425e64db52ec0a2dff260f4ddcf585b9c817026 /intern
parent8e81da423c403c65faa3adefc499c9047e357b8e (diff)
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.
Diffstat (limited to 'intern')
-rw-r--r--intern/cycles/kernel/svm/svm_brightness.h26
1 files changed, 5 insertions, 21 deletions
diff --git a/intern/cycles/kernel/svm/svm_brightness.h b/intern/cycles/kernel/svm/svm_brightness.h
index 698899ffd60..7514fc2f2fe 100644
--- a/intern/cycles/kernel/svm/svm_brightness.h
+++ b/intern/cycles/kernel/svm/svm_brightness.h
@@ -27,28 +27,12 @@ __device void svm_node_brightness(ShaderData *sd, float *stack, uint in_color, u
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 = a*color.x + b;
- color.y = a*color.y + b;
- color.z = a*color.z + b;
+ 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);
if (stack_valid(out_color))
stack_store_float3(stack, out_color, color);