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:
authorMatt Ebb <matt@mke3.net>2007-09-16 17:50:34 +0400
committerMatt Ebb <matt@mke3.net>2007-09-16 17:50:34 +0400
commit90daa8f81126a86f2cd419a6288b5f0b097d478b (patch)
tree4c84662f08c72e42845f8e6667aa5c190126c5c0 /source/blender/render/intern
parentc8fe5a0ed95fa15e955d3224fd6a2c8a8b648d73 (diff)
* Extra lamp falloff options, including custom curve!
This adds some new lamp attenuation options to the Lamp panel, replacing the old 'Quad' button. Yes, the panel layout is still nasty here, but I've ignored it for now to address properly in the panels cleanup work. * Constant http://mke3.net/blender/devel/rendering/falloff-constant.jpg Lamp doesn't decay with distance * Inverse Linear http://mke3.net/blender/devel/rendering/falloff-invlinear.jpg Default, and same as in older Blender without 'Quad' on. Decays linearly, with 'Dist' value as the lamp's half-energy-distance * Inverse Square http://mke3.net/blender/devel/rendering/falloff-invsquare.jpg A sharper, more realistic decay, good for most electric lights (i.e. not sunlight). This is similar to the old Quad option with slight changes. * Lin/Quad weighted Exactly the same as in older Blenders with the old 'Quad' button enabled. When this setting is chosen, two sliders are shown, 'Linear' and 'Quad' (previously Quad1 and Quad2), which controls the 'linearness' or 'quadraticness' of the falloff curve. Lamps in old files with the 'Quad' button on will be initialised to this setting. But much better for precise control over the lamp falloff now is: * Custom Curve This shows an extra 'Falloff Curve' panel, where you can use the standard Blender curve UI control to precisely control how the light falls off. The Y axis is intensity, and the X axis is distance, stretched over the length of the 'Dist' value. Some example curves and renders: http://mke3.net/blender/devel/rendering/falloff-curve1-curve.png http://mke3.net/blender/devel/rendering/falloff-curve1.jpg http://mke3.net/blender/devel/rendering/falloff-curve2-curve.png http://mke3.net/blender/devel/rendering/falloff-curve2.jpg http://mke3.net/blender/devel/rendering/falloff-curve3-curve.png http://mke3.net/blender/devel/rendering/falloff-curve3.jpg (whee)
Diffstat (limited to 'source/blender/render/intern')
-rw-r--r--source/blender/render/intern/include/render_types.h4
-rw-r--r--source/blender/render/intern/source/convertblender.c5
-rw-r--r--source/blender/render/intern/source/shadeoutput.c31
3 files changed, 31 insertions, 9 deletions
diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h
index b6d1024a081..abcdf417b62 100644
--- a/source/blender/render/intern/include/render_types.h
+++ b/source/blender/render/intern/include/render_types.h
@@ -32,6 +32,7 @@
/* exposed internal in render module only! */
/* ------------------------------------------------------------------------- */
+#include "DNA_color_types.h"
#include "DNA_scene_types.h"
#include "DNA_world_types.h"
#include "DNA_object_types.h"
@@ -324,7 +325,10 @@ typedef struct LampRen {
float vec[3];
float xsp, ysp, distkw, inpr;
float halokw, halo;
+
+ short falloff_type;
float ld1,ld2;
+ struct CurveMapping *curfalloff;
/* copied from Lamp, to decouple more rendering stuff */
/** Size of the shadowbuffer */
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index cb31c58ab2f..29b48413ca7 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -66,6 +66,7 @@
#include "BKE_action.h"
#include "BKE_curve.h"
#include "BKE_customdata.h"
+#include "BKE_colortools.h"
#include "BKE_constraint.h"
#include "BKE_displist.h"
#include "BKE_deform.h"
@@ -2221,7 +2222,6 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
lar->mode= la->mode;
lar->energy= la->energy;
- lar->energy= la->energy;
if(la->mode & LA_NEG) lar->energy= -lar->energy;
lar->vec[0]= -mat[2][0];
@@ -2312,8 +2312,10 @@ static GroupObject *add_render_lamp(Render *re, Object *ob)
lar->lay= ob->lay & 0xFFFFFF; // higher 8 bits are localview layers
+ lar->falloff_type = la->falloff_type;
lar->ld1= la->att1;
lar->ld2= la->att2;
+ lar->curfalloff = curvemapping_copy(la->curfalloff);
if(lar->type==LA_SPOT) {
@@ -2965,6 +2967,7 @@ void RE_Database_Free(Render *re)
if(lar->jitter) MEM_freeN(lar->jitter);
if(lar->shadsamp) MEM_freeN(lar->shadsamp);
if(lar->qsa) free_lamp_qmcsampler(lar);
+ curvemapping_free(lar->curfalloff);
}
BLI_freelistN(&re->lampren);
diff --git a/source/blender/render/intern/source/shadeoutput.c b/source/blender/render/intern/source/shadeoutput.c
index c8f6bd129c3..f50028e4c83 100644
--- a/source/blender/render/intern/source/shadeoutput.c
+++ b/source/blender/render/intern/source/shadeoutput.c
@@ -32,6 +32,7 @@
#include "MTC_matrixops.h"
#include "BLI_arithb.h"
+#include "BKE_colortools.h"
#include "BKE_material.h"
#include "BKE_texture.h"
#include "BKE_utildefines.h"
@@ -1056,14 +1057,26 @@ float lamp_get_visibility(LampRen *lar, float *co, float *lv, float *dist)
visifac= 0.0f;
}
else {
- if(lar->mode & LA_QUAD) {
- if(lar->ld1>0.0f)
- visifac= lar->dist/(lar->dist+lar->ld1*dist[0]);
- if(lar->ld2>0.0f)
- visifac*= lar->distkw/(lar->distkw+lar->ld2*dist[0]*dist[0]);
- }
- else {
- visifac= (lar->dist/(lar->dist+dist[0]));
+ switch(lar->falloff_type)
+ {
+ case LA_FALLOFF_CONSTANT:
+ visifac = 1.0f;
+ break;
+ case LA_FALLOFF_INVLINEAR:
+ visifac = lar->dist/(lar->dist + dist[0]);
+ break;
+ case LA_FALLOFF_INVSQUARE:
+ visifac = lar->dist / (lar->dist + dist[0]*dist[0]);
+ break;
+ case LA_FALLOFF_SLIDERS:
+ if(lar->ld1>0.0f)
+ visifac= lar->dist/(lar->dist+lar->ld1*dist[0]);
+ if(lar->ld2>0.0f)
+ visifac*= lar->distkw/(lar->distkw+lar->ld2*dist[0]*dist[0]);
+ break;
+ case LA_FALLOFF_CURVE:
+ visifac = curvemapping_evaluateF(lar->curfalloff, 0, dist[0]/lar->dist);
+ break;
}
if(lar->mode & LA_SPHERE) {
@@ -1130,6 +1143,8 @@ static void shade_one_light(LampRen *lar, ShadeInput *shi, ShadeResult *shr, int
vn= shi->vn;
view= shi->view;
+ if (lar->energy == 0.0) return;
+
/* lampdist, spot angle, area side, ... */
visifac= lamp_get_visibility(lar, shi->co, lv, &lampdist);
if(visifac==0.0f)