[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [27933] branches/render25: Render Branch: evil "local" option for material light groups.

Brecht Van Lommel brecht at blender.org
Thu Apr 1 19:11:39 CEST 2010


Revision: 27933
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=27933
Author:   blendix
Date:     2010-04-01 19:11:39 +0200 (Thu, 01 Apr 2010)

Log Message:
-----------
Render Branch: evil "local" option for material light groups. When the material
is linked in, this will use a local group instead of the linked group, so that
some objects in a linked group can be lit by separate lights.

Implementation is just a few lines in material.c, most of the changes do some
clean up for lamp related code.

Modified Paths:
--------------
    branches/render25/release/scripts/ui/properties_material.py
    branches/render25/source/blender/blenkernel/BKE_group.h
    branches/render25/source/blender/blenkernel/intern/material.c
    branches/render25/source/blender/blenloader/intern/readfile.c
    branches/render25/source/blender/editors/space_view3d/drawobject.c
    branches/render25/source/blender/makesdna/DNA_lamp_types.h
    branches/render25/source/blender/makesdna/DNA_material_types.h
    branches/render25/source/blender/makesrna/intern/rna_material.c
    branches/render25/source/blender/render/intern/include/lamp.h
    branches/render25/source/blender/render/intern/source/convertblender.c
    branches/render25/source/blender/render/intern/source/lamp.c

Modified: branches/render25/release/scripts/ui/properties_material.py
===================================================================
--- branches/render25/release/scripts/ui/properties_material.py	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/release/scripts/ui/properties_material.py	2010-04-01 17:11:39 UTC (rev 27933)
@@ -286,6 +286,7 @@
         row = sub.row()
         row.active = bool(mat.light_group)
         row.prop(mat, "light_group_exclusive", text="Exclusive")
+        row.prop(mat, "light_group_local", text="Local")
 
         if wide_ui:
             col = split.column()

Modified: branches/render25/source/blender/blenkernel/BKE_group.h
===================================================================
--- branches/render25/source/blender/blenkernel/BKE_group.h	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/blenkernel/BKE_group.h	2010-04-01 17:11:39 UTC (rev 27933)
@@ -31,6 +31,7 @@
 #ifndef BKE_GROUP_H
 #define BKE_GROUP_H
 
+struct Base;
 struct Group;
 struct GroupObject;
 struct Object;

Modified: branches/render25/source/blender/blenkernel/intern/material.c
===================================================================
--- branches/render25/source/blender/blenkernel/intern/material.c	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/blenkernel/intern/material.c	2010-04-01 17:11:39 UTC (rev 27933)
@@ -36,6 +36,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "DNA_curve_types.h"
+#include "DNA_group_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meta_types.h"
@@ -750,6 +751,15 @@
 
 	if(ma->strand_surfnor > 0.0f)
 		ma->mode_l |= MA_STR_SURFDIFF;
+	
+	/* local group override */
+	if((ma->shade_flag & MA_GROUP_LOCAL) && ma->id.lib && ma->group && ma->group->id.lib) {
+		Group *group;
+
+		for(group= G.main->group.first; group; group= group->id.next)
+			if(!group->id.lib && strcmp(group->id.name, ma->group->id.name) == 0)
+				ma->group = group;
+	}
 }
 
 static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode)

Modified: branches/render25/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/render25/source/blender/blenloader/intern/readfile.c	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/blenloader/intern/readfile.c	2010-04-01 17:11:39 UTC (rev 27933)
@@ -11270,6 +11270,8 @@
 	
 	if(ma->nodetree)
 		expand_nodetree(fd, mainvar, ma->nodetree);
+
+	expand_doit(fd, mainvar, ma->group);
 }
 
 static void expand_lamp(FileData *fd, Main *mainvar, Lamp *la)

Modified: branches/render25/source/blender/editors/space_view3d/drawobject.c
===================================================================
--- branches/render25/source/blender/editors/space_view3d/drawobject.c	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/editors/space_view3d/drawobject.c	2010-04-01 17:11:39 UTC (rev 27933)
@@ -984,7 +984,7 @@
 	glPopMatrix();	/* back in object space */
 	vec[0]= vec[1]= vec[2]= 0.0f;
 	
-	if ((la->type==LA_SPOT) || (la->type==LA_YF_PHOTON)) {	
+	if (la->type==LA_SPOT) {
 		lvec[0]=lvec[1]= 0.0; 
 		lvec[2] = 1.0;
 		x = rv3d->persmat[0][2];

Modified: branches/render25/source/blender/makesdna/DNA_lamp_types.h
===================================================================
--- branches/render25/source/blender/makesdna/DNA_lamp_types.h	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/makesdna/DNA_lamp_types.h	2010-04-01 17:11:39 UTC (rev 27933)
@@ -49,22 +49,28 @@
 	short type, flag;
 	int mode;
 	
+	/* color and power */
 	short colormodel, totex;
 	float r, g, b, k;
 	float shdwr, shdwg, shdwb;
+	float energy, power;
 	
-	float energy, power, spotsize, spotblend;
-	float haint, pad6;
+	/* spots */
+	float spotsize, spotblend, haint;
+	short shadhalostep, pad6;
 	
+	/* falloff */
 	struct CurveMapping *curfalloff;
 	short falloff_type, pad2;
 	float falloff_smooth, dist;
 	
+	/* shadow buffer */
 	float clipsta, clipend, shadspotsize;
 	float bias, soft, compressthresh, pad5;
 	short bufsize, samp, buffers, filtertype;
 	char bufflag, buftype;
 	
+	/* ray traced shadows */
 	short ray_samp;
 	short ray_samp_type;
 	short area_shape;
@@ -73,9 +79,6 @@
 	short ray_samp_method;
 	short pad1;
 	
-	/* texact is for buttons */
-	short texact, shadhalostep;
-	
 	/* sun/sky */
 	short sun_effect_type;
 	short skyblendtype;
@@ -92,18 +95,12 @@
 	float skyblendfac;
 	float sky_exposure;
 	short sky_colorspace, pad4;
-	
-	/* yafray: photonlight params */
-	int YF_numphotons, YF_numsearch;
-	short YF_phdepth, YF_useqmc, YF_bufsize, YF_pad;
-	float YF_causticblur, YF_ltradius;
-	/* yafray: glow params */
-	float YF_glowint, YF_glowofs;
-	short YF_glowtype, YF_pad2;
-	
+
 	struct Ipo *ipo;				// XXX depreceated... old animation system
+
+	/* textures */
 	struct MTex *mtex[18];			/* MAX_MTEX */
-	short pr_texture, pad[3];
+	short pr_texture, texact, pad[2];
 	
 	/* preview */
 	struct PreviewImage *preview;
@@ -124,8 +121,7 @@
 #define LA_SPOT			2
 #define LA_HEMI			3
 #define LA_AREA			4
-/* yafray: extra lamp type used for caustic photonmap */
-#define LA_YF_PHOTON	5
+#define LA_DEPRECATED	5
 
 /* mode */
 #define LA_SHAD_BUF		1

Modified: branches/render25/source/blender/makesdna/DNA_material_types.h
===================================================================
--- branches/render25/source/blender/makesdna/DNA_material_types.h	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/makesdna/DNA_material_types.h	2010-04-01 17:11:39 UTC (rev 27933)
@@ -224,7 +224,7 @@
 #define MA_TANGENT_V	0x4000000
 /* qdn: a bit clumsy this, tangents needed for normal maps separated from shading */
 #define MA_NORMAP_TANG	0x8000000
-#define MA_GROUP_NOLAY	0x10000000
+#define MA_GROUP_EXCLUSIVE		0x10000000
 #define MA_FACETEXTURE_ALPHA	0x20000000
 #define MA_STR_B_UNITS	0x40000000
 #define MA_STR_SURFDIFF 0x80000000
@@ -239,6 +239,7 @@
 #define MA_CUBIC			1
 #define MA_OBCOLOR			2
 #define MA_APPROX_OCCLUSION	4
+#define MA_GROUP_LOCAL		8
 
 /* diff_shader */
 #define MA_DIFF_LAMBERT		0

Modified: branches/render25/source/blender/makesrna/intern/rna_material.c
===================================================================
--- branches/render25/source/blender/makesrna/intern/rna_material.c	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/makesrna/intern/rna_material.c	2010-04-01 17:11:39 UTC (rev 27933)
@@ -1561,9 +1561,14 @@
 	/* flags */
 	
 	prop= RNA_def_property(srna, "light_group_exclusive", PROP_BOOLEAN, PROP_NONE);
-	RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_GROUP_NOLAY);
+	RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_GROUP_EXCLUSIVE);
 	RNA_def_property_ui_text(prop, "Light Group Exclusive", "Material uses the light group exclusively - these lamps are excluded from other scene lighting");
 	RNA_def_property_update(prop, 0, "rna_Material_update");
+
+	prop= RNA_def_property(srna, "light_group_local", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_sdna(prop, NULL, "shade_flag", MA_GROUP_LOCAL);
+	RNA_def_property_ui_text(prop, "Light Group Local", "When linked in, Material uses local light group with the same name");
+	RNA_def_property_update(prop, 0, "rna_Material_update");
 	
 	prop= RNA_def_property(srna, "traceable", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "mode", MA_TRACEBLE);

Modified: branches/render25/source/blender/render/intern/include/lamp.h
===================================================================
--- branches/render25/source/blender/render/intern/include/lamp.h	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/render/intern/include/lamp.h	2010-04-01 17:11:39 UTC (rev 27933)
@@ -157,14 +157,7 @@
 	
 	/* passes & node shader support: all shadow info for a pixel */
 	LampShadowSample *shadsamp;
-		
-	/* yafray: photonlight params */
-	int YF_numphotons, YF_numsearch;
-	short YF_phdepth, YF_useqmc, YF_bufsize;
-	float YF_causticblur, YF_ltradius;
-	float YF_glowint, YF_glowofs;
-	short YF_glowtype;
-	
+
 	/* ray optim */
 	struct RayObject *last_hit[BLENDER_MAX_THREADS];
 	

Modified: branches/render25/source/blender/render/intern/source/convertblender.c
===================================================================
--- branches/render25/source/blender/render/intern/source/convertblender.c	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/render/intern/source/convertblender.c	2010-04-01 17:11:39 UTC (rev 27933)
@@ -224,7 +224,7 @@
 	/* hola! materials not in use...? */
 	for(ma= G.main->mat.first; ma; ma=ma->id.next) {
 		if(ma->group && (ma->group->id.flag & LIB_DOIT))
-			lightgroup_create(re, ma->group, ma->mode & MA_GROUP_NOLAY);
+			lightgroup_create(re, ma->group, ma->mode & MA_GROUP_EXCLUSIVE);
 	}
 }
 

Modified: branches/render25/source/blender/render/intern/source/lamp.c
===================================================================
--- branches/render25/source/blender/render/intern/source/lamp.c	2010-04-01 14:44:31 UTC (rev 27932)
+++ branches/render25/source/blender/render/intern/source/lamp.c	2010-04-01 17:11:39 UTC (rev 27933)
@@ -40,6 +40,7 @@
 
 #include "BKE_colortools.h"
 #include "BKE_global.h"
+#include "BKE_group.h"
 
 #include "environment.h"
 #include "lamp.h"
@@ -296,7 +297,6 @@
 {
 	Material *ma= shi->material.mat;
 
-	if(lar->type==LA_YF_PHOTON) return 1;
 	if(lar->mode & LA_LAYER) if(shi->primitive.obi && (lar->lay & shi->primitive.obi->lay)==0) return 1;
 	if((lar->lay & shi->shading.lay)==0) return 1;
 	if((lar->mode & LA_NO_INDIRECT) && shi->shading.isindirect) return 1;





More information about the Bf-blender-cvs mailing list