[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57367] branches/soc-2013-dingto/intern/ cycles: Cycles / Wavelength node:

Thomas Dinges blender at dingto.org
Mon Jun 10 23:35:32 CEST 2013


Revision: 57367
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57367
Author:   dingto
Date:     2013-06-10 21:35:32 +0000 (Mon, 10 Jun 2013)
Log Message:
-----------
Cycles / Wavelength node:
* Fixed some things which came up during code review.

Modified Paths:
--------------
    branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_mix.h
    branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_wavelength.h
    branches/soc-2013-dingto/intern/cycles/util/util_math.h

Modified: branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_mix.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_mix.h	2013-06-10 21:16:29 UTC (rev 57366)
+++ branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_mix.h	2013-06-10 21:35:32 UTC (rev 57367)
@@ -20,17 +20,17 @@
 
 __device float3 svm_mix_blend(float t, float3 col1, float3 col2)
 {
-	return lerp_interp(col1, col2, t);
+	return interp(col1, col2, t);
 }
 
 __device float3 svm_mix_add(float t, float3 col1, float3 col2)
 {
-	return lerp_interp(col1, col1 + col2, t);
+	return interp(col1, col1 + col2, t);
 }
 
 __device float3 svm_mix_mul(float t, float3 col1, float3 col2)
 {
-	return lerp_interp(col1, col1 * col2, t);
+	return interp(col1, col1 * col2, t);
 }
 
 __device float3 svm_mix_screen(float t, float3 col1, float3 col2)
@@ -68,7 +68,7 @@
 
 __device float3 svm_mix_sub(float t, float3 col1, float3 col2)
 {
-	return lerp_interp(col1, col1 - col2, t);
+	return interp(col1, col1 - col2, t);
 }
 
 __device float3 svm_mix_div(float t, float3 col1, float3 col2)
@@ -86,7 +86,7 @@
 
 __device float3 svm_mix_diff(float t, float3 col1, float3 col2)
 {
-	return lerp_interp(col1, fabs(col1 - col2), t);
+	return interp(col1, fabs(col1 - col2), t);
 }
 
 __device float3 svm_mix_dark(float t, float3 col1, float3 col2)
@@ -184,7 +184,7 @@
 		hsv.x = hsv2.x;
 		float3 tmp = hsv_to_rgb(hsv); 
 
-		outcol = lerp_interp(outcol, tmp, t);
+		outcol = interp(outcol, tmp, t);
 	}
 
 	return outcol;
@@ -231,7 +231,7 @@
 		hsv.y = hsv2.y;
 		float3 tmp = hsv_to_rgb(hsv); 
 
-		outcol = lerp_interp(outcol, tmp, t);
+		outcol = interp(outcol, tmp, t);
 	}
 
 	return outcol;

Modified: branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_wavelength.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_wavelength.h	2013-06-10 21:16:29 UTC (rev 57366)
+++ branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_wavelength.h	2013-06-10 21:35:32 UTC (rev 57367)
@@ -10,13 +10,13 @@
  * modification, are permitted provided that the following conditions are
  * met:
  * * Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
+ *	 notice, this list of conditions and the following disclaimer.
  * * Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
+ *	 notice, this list of conditions and the following disclaimer in the
+ *	 documentation and/or other materials provided with the distribution.
  * * Neither the name of Sony Pictures Imageworks nor the names of its
- *   contributors may be used to endorse or promote products derived from
- *   this software without specific prior written permission.
+ *	 contributors may be used to endorse or promote products derived from
+ *	 this software without specific prior written permission.
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -37,12 +37,12 @@
 __device void svm_node_wavelength(ShaderData *sd, float *stack, uint wavelength, uint color_out)
 {	
 	// CIE colour matching functions xBar, yBar, and zBar for
-	//   wavelengths from 380 through 780 nanometers, every 5
-	//   nanometers.  For a wavelength lambda in this range:
-	//        cie_colour_match[(lambda - 380) / 5][0] = xBar
-	//        cie_colour_match[(lambda - 380) / 5][1] = yBar
-	//        cie_colour_match[(lambda - 380) / 5][2] = zBar
-	float cie_colour_match[81][3] = {
+	//	 wavelengths from 380 through 780 nanometers, every 5
+	//	 nanometers.  For a wavelength lambda in this range:
+	//		  cie_colour_match[(lambda - 380) / 5][0] = xBar
+	//		  cie_colour_match[(lambda - 380) / 5][1] = yBar
+	//		  cie_colour_match[(lambda - 380) / 5][2] = zBar
+	const float cie_colour_match[81][3] = {
 		{0.0014,0.0000,0.0065}, {0.0022,0.0001,0.0105}, {0.0042,0.0001,0.0201},
 		{0.0076,0.0002,0.0362}, {0.0143,0.0004,0.0679}, {0.0232,0.0006,0.1102},
 		{0.0435,0.0012,0.2074}, {0.0776,0.0022,0.3713}, {0.1344,0.0040,0.6456},
@@ -73,21 +73,21 @@
 	};
 
 	float lambda_nm = stack_load_float(stack, wavelength);
-    float ii = (lambda_nm-380.0f) / 5.0f;  // scaled 0..80
-    int i = float_to_int(ii);
+	float ii = (lambda_nm-380.0f) * (1.0f/5.0f);  // scaled 0..80
+	int i = float_to_int(ii);
 	float3 color;
 	
-    if (i < 0 || i >= 80) {
-        color = make_float3(0.0f, 0.0f, 0.0f);
+	if (i < 0 || i >= 80) {
+		color = make_float3(0.0f, 0.0f, 0.0f);
 	}
 	else {
 		ii -= i;
-		float *c = cie_colour_match[i];
-		color = lerp_interp(make_float3(c[0], c[1], c[2]), make_float3(c[3], c[4], c[5]), ii);
+		const float *c = cie_colour_match[i];
+		color = interp(make_float3(c[0], c[1], c[2]), make_float3(c[3], c[4], c[5]), ii);
 	}
 	
 	color = xyz_to_rgb(color.x, color.y, color.z);
-	color *= 1.0f/2.52f;    // Empirical scale from lg to make all comps <= 1
+	color *= 1.0f/2.52f;	// Empirical scale from lg to make all comps <= 1
 	
 	/* Clamp to zero if values are smaller */
 	color = max(color, make_float3(0.0f, 0.0f, 0.0f));

Modified: branches/soc-2013-dingto/intern/cycles/util/util_math.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/util/util_math.h	2013-06-10 21:16:29 UTC (rev 57366)
+++ branches/soc-2013-dingto/intern/cycles/util/util_math.h	2013-06-10 21:35:32 UTC (rev 57367)
@@ -590,11 +590,6 @@
 	return a + t*(b - a);
 }
 
-__device_inline float3 lerp_interp(const float3 a, const float3 b, float t)
-{
-	return (a * (1.0f - t) + b * t);
-}
-
 __device_inline bool is_zero(const float3 a)
 {
 #ifdef __KERNEL_SSE__




More information about the Bf-blender-cvs mailing list