[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13437] trunk/blender/source/blender/ render/intern:

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Jan 28 17:54:52 CET 2008


Revision: 13437
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13437
Author:   blendix
Date:     2008-01-28 17:54:52 +0100 (Mon, 28 Jan 2008)

Log Message:
-----------

Strands now mix together correctly with ZTransp.

They now also store a list of samples per pixel, and then get
shaded together with the ztransp samples. This comes with a
slight speed hit, but mainly memory might be a concern. However,
testing some peach scenes I haven't problems.

Modified Paths:
--------------
    trunk/blender/source/blender/render/intern/include/render_types.h
    trunk/blender/source/blender/render/intern/include/rendercore.h
    trunk/blender/source/blender/render/intern/include/strand.h
    trunk/blender/source/blender/render/intern/include/zbuf.h
    trunk/blender/source/blender/render/intern/source/envmap.c
    trunk/blender/source/blender/render/intern/source/rendercore.c
    trunk/blender/source/blender/render/intern/source/renderdatabase.c
    trunk/blender/source/blender/render/intern/source/strand.c
    trunk/blender/source/blender/render/intern/source/zbuf.c

Modified: trunk/blender/source/blender/render/intern/include/render_types.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/render_types.h	2008-01-28 16:33:59 UTC (rev 13436)
+++ trunk/blender/source/blender/render/intern/include/render_types.h	2008-01-28 16:54:52 UTC (rev 13437)
@@ -176,7 +176,6 @@
 	ListBase lampren;	/* storage, for free */
 	
 	ListBase objecttable;
-	struct RenderBuckets *strandbuckets;
 
 	struct ObjectInstanceRen *objectinstance;
 	ListBase instancetable;
@@ -334,6 +333,8 @@
     struct Material *mat;
 } HaloRen;
 
+/* ------------------------------------------------------------------------- */
+
 typedef struct StrandVert {
 	float co[3];
 	float strandco;
@@ -351,6 +352,11 @@
 	int totvert, totface;
 } StrandSurface;
 
+typedef struct StrandBound {
+	int start, end;
+	float bbox[2][3];
+} StrandBound;
+
 typedef struct StrandBuffer {
 	struct StrandBuffer *next, *prev;
 	struct StrandVert *vert;

Modified: trunk/blender/source/blender/render/intern/include/rendercore.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/rendercore.h	2008-01-28 16:33:59 UTC (rev 13436)
+++ trunk/blender/source/blender/render/intern/include/rendercore.h	2008-01-28 16:54:52 UTC (rev 13437)
@@ -91,8 +91,6 @@
 
 void zbufshade_sss_tile(struct RenderPart *pa);
 
-void addps(struct ListBase *lb, long *rd, int obi, int facenr, int z, unsigned short mask);
-
 int get_sample_layers(struct RenderPart *pa, struct RenderLayer *rl, struct RenderLayer **rlpp);
 
 

Modified: trunk/blender/source/blender/render/intern/include/strand.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/strand.h	2008-01-28 16:33:59 UTC (rev 13436)
+++ trunk/blender/source/blender/render/intern/include/strand.h	2008-01-28 16:54:52 UTC (rev 13437)
@@ -88,13 +88,20 @@
 	int shaded;
 } StrandSegment;
 
+struct StrandShadeCache;
+typedef struct StrandShadeCache StrandShadeCache;
+
 void strand_eval_point(StrandSegment *sseg, StrandPoint *spoint);
 void render_strand_segment(struct Render *re, float winmat[][4], struct StrandPart *spart, struct ZSpan *zspan, int totzspan, StrandSegment *sseg);
-void project_strands(Render *re, void (*projectfunc)(float *, float mat[][4], float *),  int do_pano, int do_buckets);
 
 struct StrandSurface *cache_strand_surface(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, float mat[][4], int timeoffset);
 void free_strand_surface(struct Render *re);
 
+struct StrandShadeCache *strand_shade_cache_create(void);
+void strand_shade_cache_free(struct StrandShadeCache *cache);
+void strand_shade_segment(struct Render *re, struct StrandShadeCache *cache, struct StrandSegment *sseg, struct ShadeSample *ssamp, float t, float s, int addpassflag);
+void strand_shade_unref(struct StrandShadeCache *cache, struct StrandVert *svert);
+
 struct RenderBuckets *init_buckets(struct Render *re);
 void add_buckets_primitive(struct RenderBuckets *buckets, float *min, float *max, void *prim);
 void free_buckets(struct RenderBuckets *buckets);

Modified: trunk/blender/source/blender/render/intern/include/zbuf.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/zbuf.h	2008-01-28 16:33:59 UTC (rev 13436)
+++ trunk/blender/source/blender/render/intern/include/zbuf.h	2008-01-28 16:54:52 UTC (rev 13437)
@@ -36,6 +36,8 @@
 struct VlakRen;
 struct ListBase;
 struct ZSpan;
+struct APixstrand;
+struct StrandShadeCache;
 
 void fillrect(int *rect, int x, int y, int val);
 
@@ -51,9 +53,9 @@
 void zbuffer_solid(struct RenderPart *pa, struct RenderLayer *rl, void (*fillfunc)(struct RenderPart*, struct ZSpan*, int, void*), void *data);
 
 unsigned short *zbuffer_transp_shade(struct RenderPart *pa, struct RenderLayer *rl, float *pass, struct ListBase *psmlist);
-unsigned short *zbuffer_strands_shade(struct Render *re, struct RenderPart *pa, struct RenderLayer *rl, float *pass);
 void convert_zbuf_to_distbuf(struct RenderPart *pa, struct RenderLayer *rl);
 void zbuffer_sss(RenderPart *pa, unsigned int lay, void *handle, void (*func)(void*, int, int, int, int, int));
+int zbuffer_strands_abuf(struct Render *re, struct RenderPart *pa, struct RenderLayer *rl, struct APixstrand *apixbuf, struct ListBase *apsmbase, struct StrandShadeCache *cache);
 
 typedef struct APixstr {
     unsigned short mask[4];		/* jitter mask */
@@ -64,10 +66,20 @@
     struct APixstr *next;
 } APixstr;
 
+typedef struct APixstrand {
+    unsigned short mask[4];		/* jitter mask */
+    int z[4];					/* distance    */
+    int p[4];					/* index       */
+	int obi[4];					/* object instance */
+	int seg[4];					/* for strands, segment number */
+	float u[4], v[4];			/* for strands, u,v coordinate in segment */
+    struct APixstrand *next;
+} APixstrand;
+
 typedef struct APixstrMain
 {
 	struct APixstrMain *next, *prev;
-	struct APixstr *ps;
+	void *ps;
 } APixstrMain;
 
 /* span fill in method, is also used to localize data for zbuffering */
@@ -85,11 +97,13 @@
 	int *rectp;								/* polygon index buffer */
 	int *recto;								/* object buffer */
 	APixstr *apixbuf, *curpstr;				/* apixbuf for transparent */
+	APixstrand *curpstrand;					/* same for strands */
 	struct ListBase *apsmbase;
 	
 	int polygon_offset;						/* offset in Z */
 	float shad_alpha;						/* copy from material, used by irregular shadbuf */
 	int mask, apsmcounter;					/* in use by apixbuf */
+	int apstrandmcounter;
 
 	float clipcrop;							/* for shadow, was in R global before */
 

Modified: trunk/blender/source/blender/render/intern/source/envmap.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/envmap.c	2008-01-28 16:33:59 UTC (rev 13436)
+++ trunk/blender/source/blender/render/intern/source/envmap.c	2008-01-28 16:54:52 UTC (rev 13437)
@@ -152,7 +152,6 @@
 	envre->totlamp= re->totlamp;
 	envre->lights= re->lights;
 	envre->objecttable= re->objecttable;
-	envre->strandbuckets= re->strandbuckets;
 	envre->customdata_names= re->customdata_names;
 	envre->raytree= re->raytree;
 	envre->totinstance= re->totinstance;
@@ -173,7 +172,6 @@
 	envre->totinstance= 0;
 	envre->lights.first= envre->lights.last= NULL;
 	envre->objecttable.first= envre->objecttable.last= NULL;
-	envre->strandbuckets= NULL;
 	envre->customdata_names.first= envre->customdata_names.last= NULL;
 	envre->raytree= NULL;
 	envre->instancetable.first= envre->instancetable.last= NULL;

Modified: trunk/blender/source/blender/render/intern/source/rendercore.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/rendercore.c	2008-01-28 16:33:59 UTC (rev 13436)
+++ trunk/blender/source/blender/render/intern/source/rendercore.c	2008-01-28 16:54:52 UTC (rev 13437)
@@ -684,7 +684,7 @@
 	lb->first= lb->last= NULL;
 }
 
-void addps(ListBase *lb, long *rd, int obi, int facenr, int z, unsigned short mask)
+static void addps(ListBase *lb, long *rd, int obi, int facenr, int z, unsigned short mask)
 {
 	PixStrMain *psm;
 	PixStr *ps, *last= NULL;
@@ -969,8 +969,8 @@
 				halo_tile(pa, rl->rectf, rl->lay);
 
 		/* transp layer */
-		if(R.flag & R_ZTRA) {
-			if(rl->layflag & SCE_LAY_ZTRA) {
+		if(R.flag & R_ZTRA || R.totstrand) {
+			if(rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) {
 				if(pa->fullresult.first) {
 					zbuffer_transp_shade(pa, rl, rl->rectf, &psmlist);
 				}
@@ -1015,51 +1015,6 @@
 			}
 		}
 
-		/* strand rendering */
-		if((rl->layflag & SCE_LAY_STRAND) && R.totstrand) {
-			if(pa->fullresult.first) {
-				zbuffer_strands_shade(&R, pa, rl, rl->rectf);
-			}
-			else {
-				float *fcol, *scol;
-				unsigned short *strandmask, *solidmask= NULL; /* 16 bits, MAX_OSA */
-				int x;
-				
-				/* allocate, but not free here, for asynchronous display of this rect in main thread */
-				rl->scolrect= MEM_callocN(4*sizeof(float)*pa->rectx*pa->recty, "strand layer");
-
-				/* swap for live updates, and it is used in zbuf.c!!! */
-				SWAP(float*, rl->scolrect, rl->rectf);
-				strandmask= zbuffer_strands_shade(&R, pa, rl, rl->rectf);
-				SWAP(float*, rl->scolrect, rl->rectf);
-
-				/* zbuffer strands only returns strandmask if there's solid rendered */
-				if(strandmask)
-					solidmask= make_solid_mask(pa);
-				
-				if(strandmask && solidmask) {
-					unsigned short *sps= solidmask, *spz= strandmask;
-					unsigned short fullmask= (1<<R.osa)-1;
-
-					fcol= rl->rectf; scol= rl->scolrect;
-					for(x=pa->rectx*pa->recty; x>0; x--, scol+=4, fcol+=4, sps++, spz++) {
-						if(*sps == fullmask)
-							addAlphaOverFloat(fcol, scol);
-						else
-							addAlphaOverFloatMask(fcol, scol, *sps, *spz);
-					}
-				}
-				else {
-					fcol= rl->rectf; scol= rl->scolrect;
-					for(x=pa->rectx*pa->recty; x>0; x--, scol+=4, fcol+=4)
-						addAlphaOverFloat(fcol, scol);
-				}
-
-				if(solidmask) MEM_freeN(solidmask);
-				if(strandmask) MEM_freeN(strandmask);
-			}
-		}
-
 		/* sky before edge */
 		if(rl->layflag & SCE_LAY_SKY)
 			sky_tile(pa, rl);
@@ -1192,8 +1147,8 @@
 			if(rl->layflag & SCE_LAY_HALO)
 				halo_tile(pa, rl->rectf, rl->lay);
 		
-		if(R.flag & R_ZTRA) {
-			if(rl->layflag & SCE_LAY_ZTRA) {
+		if(R.flag & R_ZTRA || R.totstrand) {
+			if(rl->layflag & (SCE_LAY_ZTRA|SCE_LAY_STRAND)) {
 				float *fcol, *acol;
 				int x;
 				
@@ -1211,24 +1166,6 @@
 				}
 			}
 		}
-
-		/* strand rendering */
-		if((rl->layflag & SCE_LAY_STRAND) && R.totstrand) {
-			float *fcol, *scol;
-			int x;
-			
-			/* allocate, but not free here, for asynchronous display of this rect in main thread */
-			rl->scolrect= MEM_callocN(4*sizeof(float)*pa->rectx*pa->recty, "strand layer");
-
-			/* swap for live updates */
-			SWAP(float*, rl->scolrect, rl->rectf);
-			zbuffer_strands_shade(&R, pa, rl, rl->rectf);
-			SWAP(float*, rl->scolrect, rl->rectf);
-
-			fcol= rl->rectf; scol= rl->scolrect;
-			for(x=pa->rectx*pa->recty; x>0; x--, scol+=4, fcol+=4)
-				addAlphaOverFloat(fcol, scol);
-		}
 		
 		/* sky before edge */
 		if(rl->layflag & SCE_LAY_SKY)

Modified: trunk/blender/source/blender/render/intern/source/renderdatabase.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/renderdatabase.c	2008-01-28 16:33:59 UTC (rev 13436)

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list