[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57525] branches/soc-2013-dingto/intern/ cycles: Cycles / Blackbody node:
Thomas Dinges
blender at dingto.org
Mon Jun 17 18:12:55 CEST 2013
Revision: 57525
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57525
Author: dingto
Date: 2013-06-17 16:12:55 +0000 (Mon, 17 Jun 2013)
Log Message:
-----------
Cycles / Blackbody node:
* Code cleanup to avoid duplicated table defines, moved them into kernel_types.h.
Modified Paths:
--------------
branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h
branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_blackbody.h
branches/soc-2013-dingto/intern/cycles/render/blackbody.cpp
Modified: branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h 2013-06-17 16:01:37 UTC (rev 57524)
+++ branches/soc-2013-dingto/intern/cycles/kernel/kernel_types.h 2013-06-17 16:12:55 UTC (rev 57525)
@@ -44,6 +44,12 @@
#define BSSRDF_MIN_RADIUS 1e-8f
#define BSSRDF_MAX_ATTEMPTS 8
+#define BB_DRAPPER 800.0
+#define BB_MAX_TABLE_RANGE 12000.0
+#define BB_TABLE_XPOWER 1.5
+#define BB_TABLE_YPOWER 5.0
+#define BB_TABLE_SPACING 2.0
+
#define TEX_NUM_FLOAT_IMAGES 5
/* device capabilities */
Modified: branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_blackbody.h
===================================================================
--- branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_blackbody.h 2013-06-17 16:01:37 UTC (rev 57524)
+++ branches/soc-2013-dingto/intern/cycles/kernel/svm/svm_blackbody.h 2013-06-17 16:12:55 UTC (rev 57525)
@@ -36,31 +36,24 @@
__device void svm_node_blackbody(KernelGlobals *kg, ShaderData *sd, float *stack, uint temperature_offset, uint col_offset)
{
- /* ToDo: move those defines to kernel_types.h ? */
- float bb_drapper = 800.0f;
- float bb_max_table_range = 12000.0f;
- float bb_table_xpower = 1.5f;
- float bb_table_ypower = 5.0f;
- float bb_table_spacing = 2.0f;
-
/* Output */
float3 color_rgb = make_float3(0.0f, 0.0f, 0.0f);
/* Input */
float temperature = stack_load_float(stack, temperature_offset);
- if (temperature < bb_drapper) {
+ if (temperature < BB_DRAPPER) {
/* just return very very dim red */
color_rgb = make_float3(1.0e-6f,0.0f,0.0f);
}
- else if (temperature <= bb_max_table_range) {
+ else if (temperature <= BB_MAX_TABLE_RANGE) {
/* This is the overall size of the table (317*3+3) */
const int lookuptablesize = 954;
const float lookuptablesizef = 954.0f;
/* reconstruct a proper index for the table lookup, compared to OSL we don't look up two colors
just one (the OSL-lerp is also automatically done for us by "lookup_table_read") */
- float t = powf ((temperature - bb_drapper) / bb_table_spacing, 1.0f/bb_table_xpower);
+ float t = powf ((temperature - BB_DRAPPER) / BB_TABLE_SPACING, 1.0f/BB_TABLE_XPOWER);
int blackbody_table_offset = kernel_data.blackbody.table_offset;
@@ -72,9 +65,9 @@
lutval = (t + 317.0f*2.0f)/lookuptablesizef;
float B = lookup_table_read(kg, lutval, blackbody_table_offset, lookuptablesize);
- R = powf(R, bb_table_ypower);
- G = powf(G, bb_table_ypower);
- B = powf(B, bb_table_ypower);
+ R = powf(R, BB_TABLE_YPOWER);
+ G = powf(G, BB_TABLE_YPOWER);
+ B = powf(B, BB_TABLE_YPOWER);
/* Luminance */
float l = linear_rgb_to_gray(make_float3(R, G, B));
Modified: branches/soc-2013-dingto/intern/cycles/render/blackbody.cpp
===================================================================
--- branches/soc-2013-dingto/intern/cycles/render/blackbody.cpp 2013-06-17 16:01:37 UTC (rev 57524)
+++ branches/soc-2013-dingto/intern/cycles/render/blackbody.cpp 2013-06-17 16:12:55 UTC (rev 57525)
@@ -34,6 +34,8 @@
#include "util_color.h"
#include "util_math.h"
+#include "kernel_types.h"
+
CCL_NAMESPACE_BEGIN
vector<float> blackbody_table()
@@ -94,18 +96,11 @@
/* Blackbody table from 800 to 12k Kelvin (317 entries) */
vector<float> blackbody_table(317*3+3);
- /* ToDo: move those defines to kernel_types.h ? */
- float bb_drapper = 800.0f;
- float bb_max_table_range = 12000.0f;
- float bb_table_xpower = 1.5f;
- float bb_table_ypower = 5.0f;
- float bb_table_spacing = 2.0f;
-
float X, Y, Z;
/* ToDo: bring this back to what OSL does with the lastTemperature limit ? */
for (int i = 0; i <= 317; ++i) {
- float Temperature = powf (float(i), bb_table_xpower) * bb_table_spacing + bb_drapper;
+ float Temperature = powf (float(i), BB_TABLE_XPOWER) * BB_TABLE_SPACING + BB_DRAPPER;
X = 0;
Y = 0;
Z = 0;
@@ -130,9 +125,9 @@
/* Clamp to zero if values are smaller */
col = max(col, make_float3(0.0f, 0.0f, 0.0f));
- col.x = powf(col.x, 1.0f / bb_table_ypower);
- col.y = powf(col.y, 1.0f / bb_table_ypower);
- col.z = powf(col.z, 1.0f / bb_table_ypower);
+ col.x = powf(col.x, 1.0f / BB_TABLE_YPOWER);
+ col.y = powf(col.y, 1.0f / BB_TABLE_YPOWER);
+ col.z = powf(col.z, 1.0f / BB_TABLE_YPOWER);
/* Store in table in RRRGGGBBB format */
blackbody_table[i] = col.x;
More information about the Bf-blender-cvs
mailing list