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:
authorThomas Dinges <blender@dingto.org>2014-06-14 01:40:39 +0400
committerThomas Dinges <blender@dingto.org>2014-06-14 01:40:54 +0400
commit0ce3a755f83b047f49f78da1729a73b56b9c9d55 (patch)
tree2223b355e1c994db2225cdf85860d9d9e652fb35 /intern/cycles/util
parent7e205836884e892995105518791ab49816da37ef (diff)
Cycles: Add support for uchar4 attributes.
* Added support for uchar4 attributes to Cycles' attribute system. * This is used for Vertex Colors now, which saves some memory (4 unsigned characters, instead of 4 floats). * GPU Texture Limit on sm_20 and sm_21 decreased from 95 to 94, because we need a new texture for the uchar4 attributes. This is no problem for sm_30 or newer. Part of my GSoC 2014.
Diffstat (limited to 'intern/cycles/util')
-rw-r--r--intern/cycles/util/util_color.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/intern/cycles/util/util_color.h b/intern/cycles/util/util_color.h
index d566e1bf359..d362c8abe25 100644
--- a/intern/cycles/util/util_color.h
+++ b/intern/cycles/util/util_color.h
@@ -26,6 +26,27 @@
CCL_NAMESPACE_BEGIN
+ccl_device uchar float_to_byte(float val)
+{
+ return ((val <= 0.0f) ? 0 : (((val) > (1.0f - 0.5f / 255.0f)) ? 255 : ((255.0f * (val)) + 0.5f)));
+}
+
+ccl_device uchar4 color_float_to_byte(float3 c)
+{
+ uchar r, g, b;
+
+ r = float_to_byte(c.x);
+ g = float_to_byte(c.y);
+ b = float_to_byte(c.z);
+
+ return make_uchar4(r, g, b, 0);
+}
+
+ccl_device_inline float3 color_byte_to_float(uchar4 c)
+{
+ return make_float3(c.x*(1.0f/255.0f), c.y*(1.0f/255.0f), c.z*(1.0f/255.0f));
+}
+
ccl_device float color_srgb_to_scene_linear(float c)
{
if(c < 0.04045f)