[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [13276] trunk/blender/source/blender:

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Jan 17 20:27:16 CET 2008


Revision: 13276
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=13276
Author:   blendix
Date:     2008-01-17 20:27:16 +0100 (Thu, 17 Jan 2008)

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

Approximate Ambient Occlusion
=============================

A new approximate ambient occlusion method has been added, next to the
existing one based on raytracing. This method is specifically targetted
at use in animations, since it is inherently noise free, and so will
not flicker across frames.

http://www.blender.org/development/current-projects/changes-since-244/approximate-ambient-occlusion/
http://peach.blender.org/index.php/approximate-ambient-occlusion/

Further improvements are still needed, but it can be tested already. There
are still a number of known issues:

- Bias errors on backfaces.
- For performance, instanced object do not occlude currently.
- Sky textures don't work well, the derivatives for texture evaluation
  are not correct.
- Multiple passes do not work entirely correct (they are not accurate
  to begin with, but could be better).

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/world.c
    trunk/blender/source/blender/blenloader/intern/readfile.c
    trunk/blender/source/blender/makesdna/DNA_world_types.h
    trunk/blender/source/blender/render/extern/include/RE_shader_ext.h
    trunk/blender/source/blender/render/intern/include/render_types.h
    trunk/blender/source/blender/render/intern/include/renderdatabase.h
    trunk/blender/source/blender/render/intern/include/shading.h
    trunk/blender/source/blender/render/intern/source/convertblender.c
    trunk/blender/source/blender/render/intern/source/pipeline.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/shadeinput.c
    trunk/blender/source/blender/render/intern/source/shadeoutput.c
    trunk/blender/source/blender/render/intern/source/strand.c
    trunk/blender/source/blender/render/intern/source/texture.c
    trunk/blender/source/blender/src/buttons_shading.c

Added Paths:
-----------
    trunk/blender/source/blender/render/intern/include/occlusion.h
    trunk/blender/source/blender/render/intern/source/occlusion.c

Modified: trunk/blender/source/blender/blenkernel/intern/world.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/world.c	2008-01-17 19:01:58 UTC (rev 13275)
+++ trunk/blender/source/blender/blenkernel/intern/world.c	2008-01-17 19:27:16 UTC (rev 13276)
@@ -98,12 +98,12 @@
 	wrld->exp= 0.0f;
 	wrld->exposure=wrld->range= 1.0f;
 
-	wrld->aodist= 5.0;
+	wrld->aodist= 5.0f;
 	wrld->aosamp= 5;
-	wrld->aoenergy= 1.0;
-	wrld->aobias= 0.05;
+	wrld->aoenergy= 1.0f;
+	wrld->aobias= 0.05f;
 	wrld->ao_samp_method = WO_AOSAMP_HAMMERSLEY;	
-
+	wrld->ao_approx_error= 0.25f;
 	
 	wrld->physicsEngine= WOPHY_BULLET;//WOPHY_SUMO; Bullet by default
 	wrld->preview = NULL;

Modified: trunk/blender/source/blender/blenloader/intern/readfile.c
===================================================================
--- trunk/blender/source/blender/blenloader/intern/readfile.c	2008-01-17 19:01:58 UTC (rev 13275)
+++ trunk/blender/source/blender/blenloader/intern/readfile.c	2008-01-17 19:27:16 UTC (rev 13276)
@@ -6698,6 +6698,7 @@
 		Lamp *la;
 		Material *ma;
 		ParticleSettings *part;
+		World *wrld;
 		Mesh *me;
 		
 		/* unless the file was created 2.44.3 but not 2.45, update the constraints */
@@ -6878,6 +6879,11 @@
 			}
 		}
 
+		for(wrld=main->world.first; wrld; wrld= wrld->id.next) {
+			if(wrld->ao_approx_error == 0.0f)
+				wrld->ao_approx_error= 0.25f;
+		}
+
 		if (main->versionfile < 245 || main->subversionfile < 12)
 		{
 			/* initialize skeleton generation toolsettings */

Modified: trunk/blender/source/blender/makesdna/DNA_world_types.h
===================================================================
--- trunk/blender/source/blender/makesdna/DNA_world_types.h	2008-01-17 19:01:58 UTC (rev 13275)
+++ trunk/blender/source/blender/makesdna/DNA_world_types.h	2008-01-17 19:27:16 UTC (rev 13276)
@@ -104,9 +104,8 @@
 	float aodist, aodistfac, aoenergy, aobias;
 	short aomode, aosamp, aomix, aocolor;
 	float ao_adapt_thresh, ao_adapt_speed_fac;
-	float pad2[2];
-	short ao_samp_method;
-	short pad1[3];
+	float ao_approx_error, ao_approx_correction;
+	short ao_samp_method, ao_gather_method, ao_approx_passes, pad1;
 	
 	float *aosphere, *aotables;
 	
@@ -151,12 +150,17 @@
 /* aomode (use distances & random sampling modes) */
 #define WO_AODIST		1
 #define WO_AORNDSMP		2
+#define WO_AOCACHE		4
 
 /* aocolor */
 #define WO_AOPLAIN	0
 #define WO_AOSKYCOL	1
 #define WO_AOSKYTEX	2
 
+/* ao_gather_method */
+#define WO_AOGATHER_RAYTRACE	0
+#define WO_AOGATHER_APPROX		1
+
 /* texco (also in DNA_material_types.h) */
 #define TEXCO_ANGMAP	64
 #define TEXCO_H_SPHEREMAP	256

Modified: trunk/blender/source/blender/render/extern/include/RE_shader_ext.h
===================================================================
--- trunk/blender/source/blender/render/extern/include/RE_shader_ext.h	2008-01-17 19:01:58 UTC (rev 13275)
+++ trunk/blender/source/blender/render/extern/include/RE_shader_ext.h	2008-01-17 19:27:16 UTC (rev 13276)
@@ -64,6 +64,7 @@
 	
 	struct Material *mat;
 	struct VlakRen *vlr;
+	struct StrandRen *strand;
 	struct ObjectInstanceRen *obi;
 	struct ObjectRen *obr;
 	int facenr;
@@ -96,6 +97,7 @@
 	
 	struct Material *mat;
 	struct VlakRen *vlr;
+	struct StrandRen *strand;
 	struct ObjectInstanceRen *obi;
 	struct ObjectRen *obr;
 	int facenr;
@@ -132,7 +134,7 @@
 	/* texture coordinates */
 	float lo[3], gl[3], ref[3], orn[3], winco[3], sticky[3], vcol[4], rad[3];
 	float refcol[4], displace[3];
-	float strand, tang[3], stress, winspeed[4];
+	float strandco, tang[3], stress, winspeed[4];
 	float duplilo[3], dupliuv[3];
 
 	ShadeInputUV uv[8];   /* 8 = MAX_MTFACE */

Added: trunk/blender/source/blender/render/intern/include/occlusion.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/occlusion.h	                        (rev 0)
+++ trunk/blender/source/blender/render/intern/include/occlusion.h	2008-01-17 19:27:16 UTC (rev 13276)
@@ -0,0 +1,51 @@
+/* 
+ * $Id$
+ *
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2008 Blender Foundation.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Brecht Van Lommel.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#ifndef OCCLUSION_H
+#define OCCLUSION_H
+
+struct Render;
+struct ShadeInput;
+struct ShadeResult;
+struct RenderPart;
+struct ShadeSample;
+struct DerivedMesh;
+struct ObjectRen;
+
+void make_occ_tree(struct Render *re);
+void free_occ(struct Render *re);
+void sample_occ(struct Render *re, struct ShadeInput *shi);
+
+void cache_occ_samples(struct Render *re, struct RenderPart *pa, struct ShadeSample *ssamp);
+void free_occ_samples(struct Render *re, struct RenderPart *pa);
+
+void *cache_occ_mesh(struct Render *re, struct ObjectRen *obr, struct DerivedMesh *dm, float mat[][4]);
+
+#endif
+

Modified: trunk/blender/source/blender/render/intern/include/render_types.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/render_types.h	2008-01-17 19:01:58 UTC (rev 13275)
+++ trunk/blender/source/blender/render/intern/include/render_types.h	2008-01-17 19:27:16 UTC (rev 13276)
@@ -158,6 +158,10 @@
 	
 	/* octree tables and variables for raytrace */
 	void *raytree;
+
+	/* occlusion tree */
+	void *occlusiontree;
+	ListBase occlusionmesh;
 	
 	/* use this instead of R.r.cfra */
 	float cfra;	
@@ -341,6 +345,7 @@
 
 	struct ObjectRen *obr;
 	struct Material *ma;
+	void *occlusionmesh;
 	unsigned int lay;
 	int overrideuv;
 	int flag, maxdepth;

Modified: trunk/blender/source/blender/render/intern/include/renderdatabase.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/renderdatabase.h	2008-01-17 19:01:58 UTC (rev 13275)
+++ trunk/blender/source/blender/render/intern/include/renderdatabase.h	2008-01-17 19:27:16 UTC (rev 13276)
@@ -70,6 +70,7 @@
 	float *winspeed;
 	float *surfnor;
 	float *simplify;
+	int *face;
 	struct MCol *mcol;
 	float *uv;
 	int totuv, totmcol;
@@ -114,6 +115,7 @@
 float *RE_strandren_get_uv(struct ObjectRen *obr, struct StrandRen *strand, int n, char **name, int verify);
 struct MCol *RE_strandren_get_mcol(struct ObjectRen *obr, struct StrandRen *strand, int n, char **name, int verify);
 float *RE_strandren_get_simplify(struct ObjectRen *obr, struct StrandRen *strand, int verify);
+int *RE_strandren_get_face(struct ObjectRen *obr, struct StrandRen *strand, int verify);
 float *RE_strandren_get_winspeed(struct ObjectInstanceRen *obi, struct StrandRen *strand, int verify);
 
 struct VertRen *RE_vertren_copy(struct ObjectRen *obr, struct VertRen *ver);

Modified: trunk/blender/source/blender/render/intern/include/shading.h
===================================================================
--- trunk/blender/source/blender/render/intern/include/shading.h	2008-01-17 19:01:58 UTC (rev 13275)
+++ trunk/blender/source/blender/render/intern/include/shading.h	2008-01-17 19:27:16 UTC (rev 13276)
@@ -69,6 +69,7 @@
 
 void shade_sample_initialize(struct ShadeSample *ssamp, struct RenderPart *pa, struct RenderLayer *rl);
 void shade_samples_do_AO(struct ShadeSample *ssamp);
+void shade_samples_fill_with_ps(struct ShadeSample *ssamp, struct PixStr *ps, int x, int y);
 int shade_samples(struct ShadeSample *ssamp, struct PixStr *ps, int x, int y);
 
 void vlr_set_uv_indices(struct VlakRen *vlr, int *i1, int *i2, int *i3);

Modified: trunk/blender/source/blender/render/intern/source/convertblender.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/convertblender.c	2008-01-17 19:01:58 UTC (rev 13275)
+++ trunk/blender/source/blender/render/intern/source/convertblender.c	2008-01-17 19:27:16 UTC (rev 13276)
@@ -100,6 +100,7 @@
 
 #include "envmap.h"
 #include "multires.h"
+#include "occlusion.h"
 #include "render_types.h"
 #include "rendercore.h"
 #include "renderdatabase.h"
@@ -1497,7 +1498,7 @@
 	float *orco=0,*surfnor=0,*uvco=0, strandlen=0.0f, curlen=0.0f;
 	float hasize, pa_size, pa_time, r_tilt, cfra=bsystem_time(ob,(float)CFRA,0.0);
 	float adapt_angle=0.0, adapt_pix=0.0, random, simplify[2];
-	int i, a, k, max_k=0, totpart, totuv=0, override_uv=-1, dosimplify = 0;
+	int i, a, k, max_k=0, totpart, totuv=0, override_uv=-1, dosimplify = 0, doapproxao = 0;
 	int path_possible=0, keys_possible=0, baked_keys=0, totchild=psys->totchild;
 	int seed, path_nbr=0, path=0, orco1=0, adapt=0, uv[3]={0,0,0}, num;
 	char **uv_name=0;
@@ -1656,6 +1657,10 @@
 					strandbuf->flag |= R_STRAND_B_UNITS;
 
 				svert= strandbuf->vert;
+
+				if((re->wrld.mode & WO_AMB_OCC) && (re->wrld.ao_gather_method == WO_AOGATHER_APPROX))
+					if(ma->amb != 0.0f)
+						doapproxao= 1;
 			}
 		}
 	}
@@ -1704,15 +1709,15 @@
 			else
 				psys_particle_on_emitter(ob, psmd,part->from,pa->num,pa->num_dmcache,pa->fuv,pa->foffset,co,nor,0,0,orco,0);
 
+			num= pa->num_dmcache;
+
+			if(num == DMCACHE_NOTFOUND)
+				if(pa->num < psmd->dm->getNumFaces(psmd->dm))
+					num= pa->num;
+
 			if(uvco && ELEM(part->from,PART_FROM_FACE,PART_FROM_VOLUME)){
 				layer=psmd->dm->faceData.layers + CustomData_get_layer_index(&psmd->dm->faceData,CD_MFACE);
 
-	            num= pa->num_dmcache;
-
-				if(num == DMCACHE_NOTFOUND)
-					if(pa->num < psmd->dm->getNumFaces(psmd->dm))
-						num= pa->num;
-
 				for(i=0; i<totuv; i++){
 					if(num != DMCACHE_NOTFOUND) {
 						MFace *mface=psmd->dm->getFaceData(psmd->dm,num,CD_MFACE);
@@ -1761,6 +1766,8 @@
 
 			r_tilt=2.0f*cpa->rand[2];
 
+			num= cpa->num;
+
 			/* get orco */
 			psys_particle_on_emitter(ob, psmd,

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list