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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-08 00:24:38 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-08 00:24:38 +0400
commite6a84eb1b542e7cafe5e760530882bb806f3c433 (patch)
treee3d7b9f8dab6c2d55ec0d45297ba281599f3e92f /intern/cycles/kernel/svm/svm_light_path.h
parentf44e80e6387601dea6e4e0801d0a387455a02d31 (diff)
Cycles: add light falloff node, with quadratic/linear/constant falloff and a
smoothing factor to reduce high values near the light. http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Nodes/More#Light_Falloff Note that this was already possible to do manually with the Ray Length, but this adds a convenient node for it. This commit also makes the mapping node min/max option work, fixing #31348.
Diffstat (limited to 'intern/cycles/kernel/svm/svm_light_path.h')
-rw-r--r--intern/cycles/kernel/svm/svm_light_path.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/intern/cycles/kernel/svm/svm_light_path.h b/intern/cycles/kernel/svm/svm_light_path.h
index ebbcb5be61f..b29dc9cbd45 100644
--- a/intern/cycles/kernel/svm/svm_light_path.h
+++ b/intern/cycles/kernel/svm/svm_light_path.h
@@ -39,5 +39,32 @@ __device void svm_node_light_path(ShaderData *sd, float *stack, uint type, uint
stack_store_float(stack, out_offset, info);
}
+/* Light Falloff Node */
+
+__device void svm_node_light_falloff(ShaderData *sd, float *stack, uint4 node)
+{
+ uint strength_offset, out_offset, smooth_offset;
+
+ decode_node_uchar4(node.z, &strength_offset, &smooth_offset, &out_offset, NULL);
+
+ float strength = stack_load_float(stack, strength_offset);
+ uint type = node.y;
+
+ switch(type) {
+ case NODE_LIGHT_FALLOFF_QUADRATIC: break;
+ case NODE_LIGHT_FALLOFF_LINEAR: strength *= sd->ray_length; break;
+ case NODE_LIGHT_FALLOFF_CONSTANT: strength *= sd->ray_length*sd->ray_length; break;
+ }
+
+ float smooth = stack_load_float(stack, smooth_offset);
+
+ if(smooth > 0.0f) {
+ float squared = sd->ray_length*sd->ray_length;
+ strength *= squared/(smooth + squared);
+ }
+
+ stack_store_float(stack, out_offset, strength);
+}
+
CCL_NAMESPACE_END