[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [26610] branches/render25: Render Branch: lamp falloff
Brecht Van Lommel
brecht at blender.org
Thu Feb 4 21:41:49 CET 2010
Revision: 26610
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=26610
Author: blendix
Date: 2010-02-04 21:41:49 +0100 (Thu, 04 Feb 2010)
Log Message:
-----------
Render Branch: lamp falloff
* Change lamp falloff formula which was dist/(r^2 + dist) with dist
a user specified value, whereas the correct value is 1/(r^2). Now
it is 1/(r^2 + dist) with dist = 0 as the default.
* Deprecated the Lin/Quad weighted mode.
* Still more work needed to make sun/area/hemi work better with this,
results are too bright now.
* Also this gives quite harsh results when the lamp is near geometry,
perhaps because we are not using tonemapping by default.
Modified Paths:
--------------
branches/render25/release/scripts/ui/properties_data_lamp.py
branches/render25/source/blender/blenkernel/intern/object.c
branches/render25/source/blender/blenloader/intern/readfile.c
branches/render25/source/blender/makesdna/DNA_lamp_types.h
branches/render25/source/blender/makesrna/intern/rna_lamp.c
branches/render25/source/blender/render/intern/source/lamp.c
Modified: branches/render25/release/scripts/ui/properties_data_lamp.py
===================================================================
--- branches/render25/release/scripts/ui/properties_data_lamp.py 2010-02-04 20:33:04 UTC (rev 26609)
+++ branches/render25/release/scripts/ui/properties_data_lamp.py 2010-02-04 20:41:49 UTC (rev 26610)
@@ -94,7 +94,7 @@
if lamp.type in ('POINT', 'SPOT'):
sub.label(text="Falloff:")
sub.prop(lamp, "falloff_type", text="")
- sub.prop(lamp, "distance")
+ sub.prop(lamp, "falloff_distance", text="Distance")
if lamp.falloff_type == 'LINEAR_QUADRATIC_WEIGHTED':
col.label(text="Attenuation Factors:")
@@ -105,7 +105,7 @@
col.prop(lamp, "sphere")
if lamp.type == 'AREA':
- col.prop(lamp, "distance")
+ col.prop(lamp, "fallof_distance", text="Distance")
col.prop(lamp, "gamma")
if wide_ui:
Modified: branches/render25/source/blender/blenkernel/intern/object.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/object.c 2010-02-04 20:33:04 UTC (rev 26609)
+++ branches/render25/source/blender/blenkernel/intern/object.c 2010-02-04 20:41:49 UTC (rev 26610)
@@ -788,8 +788,8 @@
la->r= la->g= la->b= la->k= 1.0f;
la->haint= 1.0f;
- la->energy= 100.0f;
- la->dist= 25.0f;
+ la->energy= 80.0f;
+ la->dist= 0.0f;
la->spotsize= 45.0f;
la->spotblend= 0.15f;
la->att2= 1.0f;
Modified: branches/render25/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/render25/source/blender/blenloader/intern/readfile.c 2010-02-04 20:33:04 UTC (rev 26609)
+++ branches/render25/source/blender/blenloader/intern/readfile.c 2010-02-04 20:41:49 UTC (rev 26610)
@@ -6485,8 +6485,10 @@
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;
+ if(la->falloff_type == LA_FALLOFF_SLIDERS)
+ la->falloff_type= LA_FALLOFF_INVSQUARE;
- la->energy *= M_PI;
+ la->energy *= M_PI*la->dist;
}
}
Modified: branches/render25/source/blender/makesdna/DNA_lamp_types.h
===================================================================
--- branches/render25/source/blender/makesdna/DNA_lamp_types.h 2010-02-04 20:33:04 UTC (rev 26609)
+++ branches/render25/source/blender/makesdna/DNA_lamp_types.h 2010-02-04 20:41:49 UTC (rev 26610)
@@ -158,12 +158,11 @@
/* falloff_type */
#define LA_FALLOFF_CONSTANT 0
-#define LA_FALLOFF_INVLINEAR 1
+#define LA_FALLOFF_INVLINEAR 1
#define LA_FALLOFF_INVSQUARE 2
#define LA_FALLOFF_CURVE 3
-#define LA_FALLOFF_SLIDERS 4
+#define LA_FALLOFF_SLIDERS 4 /* deprecated */
-
/* buftype, no flag */
#define LA_SHADBUF_REGULAR 0
#define LA_SHADBUF_IRREGULAR 1
Modified: branches/render25/source/blender/makesrna/intern/rna_lamp.c
===================================================================
--- branches/render25/source/blender/makesrna/intern/rna_lamp.c 2010-02-04 20:33:04 UTC (rev 26609)
+++ branches/render25/source/blender/makesrna/intern/rna_lamp.c 2010-02-04 20:41:49 UTC (rev 26610)
@@ -325,10 +325,10 @@
RNA_def_property_ui_text(prop, "Type", "Type of Lamp.");
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
- prop= RNA_def_property(srna, "distance", PROP_FLOAT, PROP_DISTANCE);
+ prop= RNA_def_property(srna, "falloff_distance", PROP_FLOAT, PROP_DISTANCE);
RNA_def_property_float_sdna(prop, NULL, "dist");
RNA_def_property_ui_range(prop, 0, 1000, 1.0, 2);
- RNA_def_property_ui_text(prop, "Distance", "Falloff distance - the light is at half the original intensity at this point.");
+ RNA_def_property_ui_text(prop, "Falloff distance", "Extra distance added to falloff to smooth harsh light when the lamp is nearby.");
RNA_def_property_update(prop, 0, "rna_Lamp_draw_update");
prop= RNA_def_property(srna, "power", PROP_FLOAT, PROP_POWER);
@@ -380,7 +380,6 @@
{LA_FALLOFF_INVLINEAR, "INVERSE_LINEAR", 0, "Inverse Linear", ""},
{LA_FALLOFF_INVSQUARE, "INVERSE_SQUARE", 0, "Inverse Square", ""},
{LA_FALLOFF_CURVE, "CUSTOM_CURVE", 0, "Custom Curve", ""},
- {LA_FALLOFF_SLIDERS, "LINEAR_QUADRATIC_WEIGHTED", 0, "Lin/Quad Weighted", ""},
{0, NULL, 0, NULL, NULL}};
prop= RNA_def_property(srna, "falloff_type", PROP_ENUM, PROP_NONE);
Modified: branches/render25/source/blender/render/intern/source/lamp.c
===================================================================
--- branches/render25/source/blender/render/intern/source/lamp.c 2010-02-04 20:33:04 UTC (rev 26609)
+++ branches/render25/source/blender/render/intern/source/lamp.c 2010-02-04 20:41:49 UTC (rev 26610)
@@ -54,6 +54,8 @@
/******************************* Visibility ********************************/
+#define LAMP_FALLOFF_MIN_DIST 1e-10f /* to division by zero */
+
static float lamp_falloff(LampRen *lar, float dist)
{
float factor;
@@ -64,18 +66,11 @@
factor = 1.0f;
break;
case LA_FALLOFF_INVLINEAR:
- factor = lar->dist/(lar->dist + dist);
+ factor = 1.0f/(dist + lar->dist + LAMP_FALLOFF_MIN_DIST);
break;
case LA_FALLOFF_INVSQUARE:
- factor = lar->dist/(lar->dist + dist*dist);
+ factor = 1.0f/(dist*dist + lar->dist + LAMP_FALLOFF_MIN_DIST);
break;
- case LA_FALLOFF_SLIDERS:
- factor = 1.0f;
- if(lar->ld1>0.0f)
- factor= lar->dist/(lar->dist+lar->ld1*dist);
- if(lar->ld2>0.0f)
- factor*= lar->distkw/(lar->distkw+lar->ld2*dist*dist);
- break;
case LA_FALLOFF_CURVE:
factor = curvemapping_evaluateF(lar->curfalloff, 0, dist/lar->dist);
break;
@@ -186,7 +181,7 @@
//else
// fac= 0.0f;
- if(fac <= 0.001) fac = 0.0f;
+ if(fac <= 1e-6f) fac = 0.0f;
break;
case LA_SPOT:
@@ -202,8 +197,7 @@
if(lar->type == LA_SPOT)
fac= lamp_spot_falloff(lar, vec, fac);
- if(fac <= 0.001)
- fac = 0.0f;
+ if(fac <= 1e-6f) fac = 0.0f;
break;
}
More information about the Bf-blender-cvs
mailing list