[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26606] branches/render25: Render Branch: trying to get units figured out for materials and lamps,

Brecht Van Lommel brecht at blender.org
Thu Feb 4 18:17:01 CET 2010


Revision: 26606
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26606
Author:   blendix
Date:     2010-02-04 18:17:01 +0100 (Thu, 04 Feb 2010)

Log Message:
-----------
Render Branch: trying to get units figured out for materials and lamps,
see comments in material.h and lamp.h. Change in UI is that lamp energy
is now called power and is specified in Watts. It's still off by a large
factor due to the lamp falloff code, that will be fixed in a separate
commit.

Modified Paths:
--------------
    branches/render25/release/scripts/ui/properties_data_lamp.py
    branches/render25/source/blender/blenkernel/BKE_blender.h
    branches/render25/source/blender/blenkernel/intern/object.c
    branches/render25/source/blender/blenloader/intern/readfile.c
    branches/render25/source/blender/makesrna/RNA_types.h
    branches/render25/source/blender/makesrna/intern/makesrna.c
    branches/render25/source/blender/makesrna/intern/rna_lamp.c
    branches/render25/source/blender/render/intern/include/lamp.h
    branches/render25/source/blender/render/intern/include/material.h
    branches/render25/source/blender/render/intern/source/halo.c
    branches/render25/source/blender/render/intern/source/lamp.c
    branches/render25/source/blender/render/intern/source/material.c
    branches/render25/source/blender/render/intern/source/shadeoutput.c
    branches/render25/source/blender/render/intern/source/texture_stack.c
    branches/render25/source/blender/render/intern/source/volumetric.c

Modified: branches/render25/release/scripts/ui/properties_data_lamp.py
===================================================================
--- branches/render25/release/scripts/ui/properties_data_lamp.py	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/release/scripts/ui/properties_data_lamp.py	2010-02-04 17:17:01 UTC (rev 26606)
@@ -89,7 +89,7 @@
         col = split.column()
         sub = col.column()
         sub.prop(lamp, "color", text="")
-        sub.prop(lamp, "energy")
+        sub.prop(lamp, "power")
 
         if lamp.type in ('POINT', 'SPOT'):
             sub.label(text="Falloff:")

Modified: branches/render25/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/render25/source/blender/blenkernel/BKE_blender.h	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/source/blender/blenkernel/BKE_blender.h	2010-02-04 17:17:01 UTC (rev 26606)
@@ -43,7 +43,7 @@
 struct ReportList;
 
 #define BLENDER_VERSION			250
-#define BLENDER_SUBVERSION		15
+#define BLENDER_SUBVERSION		17
 
 #define BLENDER_MINVERSION		250
 #define BLENDER_MINSUBVERSION	0

Modified: branches/render25/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/object.c	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/source/blender/blenkernel/intern/object.c	2010-02-04 17:17:01 UTC (rev 26606)
@@ -787,7 +787,8 @@
 	la=  alloc_libblock(&G.main->lamp, ID_LA, name);
 	
 	la->r= la->g= la->b= la->k= 1.0f;
-	la->haint= la->energy= 1.0f;
+	la->haint= 1.0f;
+	la->energy= 100.0f;
 	la->dist= 25.0f;
 	la->spotsize= 45.0f;
 	la->spotblend= 0.15f;

Modified: branches/render25/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/render25/source/blender/blenloader/intern/readfile.c	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/source/blender/blenloader/intern/readfile.c	2010-02-04 17:17:01 UTC (rev 26606)
@@ -6482,9 +6482,12 @@
 		if(wo->ao_samp_method == WO_AOSAMP_CONSTANT)
 			wo->ao_samp_method= WO_AOSAMP_HAMMERSLEY;
 
-	for(la= main->lamp.first; la; la= la->id.next)
+	for(la= main->lamp.first; la; la= la->id.next) {
 		if(la->ray_samp_method == LA_SAMP_CONSTANT)
 			la->ray_samp_method= LA_SAMP_HAMMERSLEY;
+
+		la->energy *= M_PI;
+	}
 }
 
 static void do_version_constraints_radians_degrees_250(ListBase *lb)
@@ -10645,9 +10648,11 @@
 		}
 	}
 
+	if (main->versionfile < 250 || (main->versionfile == 250 && main->subversionfile < 17))
+		do_version_shading_sys_250(fd, lib, main);
+
 	/* put 2.50 compatibility code here until next subversion bump */
 	{
-		do_version_shading_sys_250(fd, lib, main);
 	}
 
 	/* WATCH IT!!!: pointers from libdata have not been converted yet here! */

Modified: branches/render25/source/blender/makesrna/RNA_types.h
===================================================================
--- branches/render25/source/blender/makesrna/RNA_types.h	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/source/blender/makesrna/RNA_types.h	2010-02-04 17:17:01 UTC (rev 26606)
@@ -78,10 +78,11 @@
 	PROP_UNIT_AREA = (2<<16),			/* m^2 */
 	PROP_UNIT_VOLUME = (3<<16),			/* m^3 */
 	PROP_UNIT_MASS = (4<<16),			/* kg */
-	PROP_UNIT_ROTATION = (5<<16),		/* rad */
+	PROP_UNIT_ROTATION = (5<<16),		/* radians */
 	PROP_UNIT_TIME = (6<<16),			/* frame */
 	PROP_UNIT_VELOCITY = (7<<16),		/* m/s */
-	PROP_UNIT_ACCELERATION = (8<<16)	/* m/(s^2) */
+	PROP_UNIT_ACCELERATION = (8<<16),	/* m/(s^2) */
+	PROP_UNIT_POWER = (9<<16)			/* Watt */
 } PropertyUnit;
 
 #define RNA_SUBTYPE_UNIT(subtype) ((subtype) & 0x00FF0000)
@@ -119,6 +120,7 @@
 	PROP_AXISANGLE = 28,
 	PROP_XYZ = 29,
 	PROP_COLOR_GAMMA = 30,
+	PROP_POWER = 31|PROP_UNIT_POWER,
 
 	/* booleans */
 	PROP_LAYER = 40,

Modified: branches/render25/source/blender/makesrna/intern/makesrna.c
===================================================================
--- branches/render25/source/blender/makesrna/intern/makesrna.c	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/source/blender/makesrna/intern/makesrna.c	2010-02-04 17:17:01 UTC (rev 26606)
@@ -1565,6 +1565,7 @@
 		case PROP_COLOR_GAMMA: return "PROP_COLOR_GAMMA";
 		case PROP_LAYER: return "PROP_LAYER";
 		case PROP_LAYER_MEMBER: return "PROP_LAYER_MEMBER";
+		case PROP_POWER: return "PROP_POWER";
 		default: {
 			/* incase we dont have a type preset that includes the subtype */
 			if(RNA_SUBTYPE_UNIT(type)) {
@@ -1589,7 +1590,8 @@
 		case PROP_UNIT_TIME:		return "PROP_UNIT_TIME";
 		case PROP_UNIT_VELOCITY:	return "PROP_UNIT_VELOCITY";
 		case PROP_UNIT_ACCELERATION:return "PROP_UNIT_ACCELERATION";
-		default: return "PROP_UNKNOWN";
+		case PROP_UNIT_POWER:		return "PROP_UNIT_POWER";
+		default:					return "PROP_UNIT_UNKNOWN";
 	}
 }
 

Modified: branches/render25/source/blender/makesrna/intern/rna_lamp.c
===================================================================
--- branches/render25/source/blender/makesrna/intern/rna_lamp.c	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/source/blender/makesrna/intern/rna_lamp.c	2010-02-04 17:17:01 UTC (rev 26606)
@@ -331,9 +331,10 @@
 	RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point.");
 	RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
 
-	prop= RNA_def_property(srna, "energy", PROP_FLOAT, PROP_NONE);
-	RNA_def_property_ui_range(prop, 0, 10.0, 0.1, 2);
-	RNA_def_property_ui_text(prop, "Energy", "Amount of light that the lamp emits.");
+	prop= RNA_def_property(srna, "power", PROP_FLOAT, PROP_POWER);
+	RNA_def_property_float_sdna(prop, NULL, "energy");
+	RNA_def_property_ui_range(prop, 0, 1000.0, 1.0, 2);
+	RNA_def_property_ui_text(prop, "Power", "Amount of light that the lamp emits in Watts.");
 	RNA_def_property_update(prop, 0, "rna_Lamp_update");
 
 	prop= RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR);

Modified: branches/render25/source/blender/render/intern/include/lamp.h
===================================================================
--- branches/render25/source/blender/render/intern/include/lamp.h	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/source/blender/render/intern/include/lamp.h	2010-02-04 17:17:01 UTC (rev 26606)
@@ -46,17 +46,18 @@
 void lightgroup_create(struct Render *re, struct Group *group, int exclusive);
 void lightgroup_free(struct Render *re);
 
-/* Visibility factor from point to center of the lamp. */
+/* Lamp unshadowed influence and shadow (for surfaces only at the moment)
+   unit of influence is irradiance (Watt/m^2) */
 
-float lamp_visibility(struct LampRen *lar, float *co, float *vn, float *r_vec, float *r_dist);
-
-/* Lamp influence and shadow on a surface */
-
 int lamp_influence(struct Render *re, struct LampRen *lar,
 	struct ShadeInput *shi, float lainf[3], float lv[3]);;
 void lamp_shadow(struct Render *re, struct LampRen *lar,
 	struct ShadeInput *shi, float lv[3], float lashdw[3]);
 
+/* Visibility factor from point to center of the lamp. */
+
+float lamp_visibility(struct LampRen *lar, float *co, float *vn, float *r_vec, float *r_dist);
+
 /* Sampling of point on the lamp */
 
 void lamp_sample(float lco[3], struct LampRen *lar, float co[3], float r[2]);
@@ -95,7 +96,7 @@
 	int mode;
 	float r, g, b, k;
 	float shdwr, shdwg, shdwb;
-	float energy, haint;
+	float power, haint;
 	int lay;
 	float spotsi,spotbl;
 	float vec[3];

Modified: branches/render25/source/blender/render/intern/include/material.h
===================================================================
--- branches/render25/source/blender/render/intern/include/material.h	2010-02-04 16:55:20 UTC (rev 26605)
+++ branches/render25/source/blender/render/intern/include/material.h	2010-02-04 17:17:01 UTC (rev 26606)
@@ -33,34 +33,48 @@
 /* Material
  *
  * Begin/end shading for a given location and view vector. Getting
- * color, alpha, bxdf, emit, .. must be done between begin and end. */
+ * color, alpha, bsdf, emit, .. must be done between begin and end. */
 
 void mat_shading_begin(struct Render *re, struct ShadeInput *shi,
 	struct ShadeMaterial *smat);
 void mat_shading_end(struct Render *re, struct ShadeMaterial *smat);
 
-/* Color and Alpha access */
+/* BSDF: combination of brdf and btdf
 
-void mat_color(float color[3], struct ShadeMaterial *mat);
-float mat_alpha(struct ShadeMaterial *mat);
+   note that we include the cos(geom->vn, lv) term in the bsdf. this
+   makes it easier to implement bsdf's that use some approximation
+   tricks. also note that for physically correct results (energy
+   conversvation) the returned values would be in the range 0 to 1/pi,
+   and have unit 1/sr */
 
-/* BXDF Access */
+#define BSDF_DIFFUSE		1
+#define BSDF_SPECULAR		2
+#define BSDF_REFLECTION		(BSDF_DIFFUSE|BSDF_SPECULAR)
+#define BSDF_TRANSMISSION	4
 
-#define BXDF_DIFFUSE		1
-#define BXDF_SPECULAR		2
-#define BXDF_TRANSMISSION	4
-#define BXDF_REFLECTION		(BXDF_DIFFUSE|BXDF_SPECULAR)
-
-void mat_bxdf_f(float bxdf[3],
+void mat_bsdf_f(float bsdf[3],
 	struct ShadeMaterial *mat, struct ShadeGeometry *geom, int thread, float lv[3], int flag);
-void mat_bxdf_sample(float lv[3], float pdf[3],
+void mat_bsdf_sample(float lv[3], float pdf[3],
 	struct ShadeMaterial *mat, struct ShadeGeometry *geom, int flag, float r[2]);
 
-/* Emission */
+/* Color: diffuse part of bsdf integrated over hemisphere, result
+   will be in the range 0 to 1 for physically correct results */
 
+void mat_color(float color[3], struct ShadeMaterial *mat);
+
+/* Color: transmission part of bsdf integrated over hemisphere, result
+   will be in the range 0 to 1 for physically correct results. 
+   converted to grayscale currently since rasterizer does not support
+   opacity values per RGB channel. */
+
+float mat_alpha(struct ShadeMaterial *mat);
+
+/* Emission: light emitted in direction geom->view
+   unit is radiance, Watt/(m^2.sr) */
+
 void mat_emit(float emit[3], struct ShadeMaterial *mat, struct ShadeGeometry *geom, int thread);
 
-/* Displacement */
+/* Displacement in camere space coordinates at current location */
 
 void mat_displacement(struct Render *re, struct ShadeInput *shi, float displacement[3]);
 

Modified: branches/render25/source/blender/render/intern/source/halo.c
===================================================================

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list