[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [21385] branches/soc-2009-jaguarandi: *Added output of BB/primitves test/hits

André Pinto andresusanopinto at gmail.com
Mon Jul 6 15:27:41 CEST 2009


Revision: 21385
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21385
Author:   jaguarandi
Date:     2009-07-06 15:27:40 +0200 (Mon, 06 Jul 2009)

Log Message:
-----------
*Added output of BB/primitves test/hits
*"Added" SCE_PASS_RAYHITS to visually see each pixel primitive and BB tests (not-completed for UI)
*Added runtime exchange of tree structure
*Removed FLOAT_EPSILON from BLI_bvhkdop BB's

Modified Paths:
--------------
    branches/soc-2009-jaguarandi/release/ui/buttons_scene.py
    branches/soc-2009-jaguarandi/source/blender/makesdna/DNA_scene_types.h
    branches/soc-2009-jaguarandi/source/blender/makesrna/intern/rna_scene.c
    branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_raytrace.h
    branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_shader_ext.h
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/pipeline.c
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject_blibvh.c
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayshade.c
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/rendercore.c
    branches/soc-2009-jaguarandi/source/blender/render/intern/source/shadeinput.c

Modified: branches/soc-2009-jaguarandi/release/ui/buttons_scene.py
===================================================================
--- branches/soc-2009-jaguarandi/release/ui/buttons_scene.py	2009-07-06 12:24:09 UTC (rev 21384)
+++ branches/soc-2009-jaguarandi/release/ui/buttons_scene.py	2009-07-06 13:27:40 UTC (rev 21385)
@@ -26,6 +26,7 @@
 		colsub = col.column()
 		colsub.active = rd.render_raytracing
 		colsub.itemR(rd, "raytrace_structure", text="Structure")
+		colsub.itemR(rd, "raytrace_tree_type", text="Tree Type")
 		colsub.itemR(rd, "octree_resolution", text="Octree")
 		col.itemR(rd, "dither_intensity", text="Dither", slider=True)
 		

Modified: branches/soc-2009-jaguarandi/source/blender/makesdna/DNA_scene_types.h
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/makesdna/DNA_scene_types.h	2009-07-06 12:24:09 UTC (rev 21384)
+++ branches/soc-2009-jaguarandi/source/blender/makesdna/DNA_scene_types.h	2009-07-06 13:27:40 UTC (rev 21385)
@@ -161,6 +161,8 @@
 #define SCE_PASS_RADIO		8192 /* Radio removed, can use for new GI? */
 #define SCE_PASS_MIST		16384
 
+#define SCE_PASS_RAYHITS	32768
+
 /* note, srl->passflag is treestore element 'nr' in outliner, short still... */
 
 
@@ -233,7 +235,8 @@
 	/* render engine, octree resolution */
 	short renderer, ocres;
 	short raystructure;
-	short pad4[3];
+	short raytrace_tree_type;
+	short pad4[2];
 
 	/**
 	 * What to do with the sky/background. Picks sky/premul/key
@@ -675,6 +678,11 @@
 #define R_RAYSTRUCTURE_SINGLE_OCTREE	2
 #define R_RAYSTRUCTURE_SINGLE_BVH		3
 
+/* raytrace tree type */
+#define R_RAYTRACE_TREE_BVH		0
+#define R_RAYTRACE_TREE_BLIBVH	1
+#define R_RAYTRACE_TREE_BIH		2
+
 /* scemode (int now) */
 #define R_DOSEQ				0x0001
 #define R_BG_RENDER			0x0002

Modified: branches/soc-2009-jaguarandi/source/blender/makesrna/intern/rna_scene.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/makesrna/intern/rna_scene.c	2009-07-06 12:24:09 UTC (rev 21384)
+++ branches/soc-2009-jaguarandi/source/blender/makesrna/intern/rna_scene.c	2009-07-06 13:27:40 UTC (rev 21385)
@@ -293,6 +293,12 @@
 		{R_RAYSTRUCTURE_SINGLE_BVH, "{R_RAYSTRUCTURE_SINGLE_BVH", 0, "Single BVH", "BVH of all primitives (no instance support)"},
 		{R_RAYSTRUCTURE_SINGLE_OCTREE, "{R_RAYSTRUCTURE_SINGLE_OCTREE", 0, "Octree", "Octree of all primitives (no instance support)"},
 		{0, NULL, 0, NULL, NULL}};
+
+	static EnumPropertyItem raytrace_tree_type_items[] = {
+		{R_RAYTRACE_TREE_BVH, "{R_RAYTRACE_TREE_BVH", 0, "BVH", "rayobject_bvh.c"},
+		{R_RAYTRACE_TREE_BLIBVH, "{R_RAYTRACE_TREE_BLIBVH", 0, "BLIbvh", "rayobject_blibvh.c"},
+		{R_RAYTRACE_TREE_BIH, "{R_RAYSTRUCTURE_SINGLE_BVH", 0, "BIH", "rayobject_bih.c"},
+		{0, NULL, 0, NULL, NULL}};
 		
 	static EnumPropertyItem fixed_oversample_items[] = {
 		{5, "OVERSAMPLE_5", 0, "5", ""},
@@ -694,6 +700,12 @@
 	RNA_def_property_enum_items(prop, raytrace_structure_items);
 	RNA_def_property_ui_text(prop, "Raytrace Acceleration Structure", "Type of raytrace accelerator structure.");
 	RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
+
+	prop= RNA_def_property(srna, "raytrace_tree_type", PROP_ENUM, PROP_NONE);
+	RNA_def_property_enum_sdna(prop, NULL, "raytrace_tree_type");
+	RNA_def_property_enum_items(prop, raytrace_tree_type_items);
+	RNA_def_property_ui_text(prop, "Raytrace tree type", "Type of raytrace accelerator structure.");
+	RNA_def_property_update(prop, NC_SCENE|ND_RENDER_OPTIONS, NULL);
 	
 	prop= RNA_def_property(srna, "antialiasing", PROP_BOOLEAN, PROP_NONE);
 	RNA_def_property_boolean_sdna(prop, NULL, "mode", R_OSA);

Modified: branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_raytrace.h
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_raytrace.h	2009-07-06 12:24:09 UTC (rev 21384)
+++ branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_raytrace.h	2009-07-06 13:27:40 UTC (rev 21385)
@@ -31,12 +31,43 @@
 #ifndef RE_RAYTRACE_H
 #define RE_RAYTRACE_H
 
-#define RE_RAY_COUNTER
+#define RE_RAYCOUNTER
+#ifdef RE_RAYCOUNTER
 
+typedef struct RayCounter RayCounter;
+struct RayCounter
+{
+
+	struct
+	{
+		unsigned long long test, hit;
+		
+	} faces, bb, raycast;
+	
+	unsigned long long rayshadow_last_hit_optimization;
+};
+
+/* #define RE_RC_INIT(isec, shi) (isec).count = re_rc_counter+(shi).thread */
+#define RE_RC_INIT(isec, shi) (isec).raycounter = &((shi).raycounter)
+void RE_RC_INFO (RayCounter *rc);
+void RE_RC_MERGE(RayCounter *rc, RayCounter *tmp);
+#define RE_RC_COUNT(var) (var)++
+
+extern RayCounter re_rc_counter[];
+
+#else
+
+#define RE_RC_INIT(isec,shi)
+#define RE_RC_INFO(rc)
+#define RE_RC_MERGE(dest,src)
+#define	RE_RC_COUNT(var)
+	
+#endif
+
+
 /* Internals about raycasting structures can be found on intern/raytree.h */
 typedef struct RayObject RayObject;
 typedef struct Isect Isect;
-typedef struct RayCounter RayCounter;
 struct DerivedMesh;
 struct Mesh;
 
@@ -50,7 +81,6 @@
 RayObject* RE_rayobject_octree_create(int ocres, int size);
 RayObject* RE_rayobject_instance_create(RayObject *target, float transform[][4], void *ob, void *target_ob);
 
-#define RE_rayobject_tree_create RE_rayobject_bvh_create
 RayObject* RE_rayobject_blibvh_create(int size);	/* BLI_kdopbvh.c   */
 RayObject* RE_rayobject_bvh_create(int size);		/* rayobject_bvh.c */
 RayObject* RE_rayobject_bih_create(int size);		/* rayobject_bih.c */
@@ -93,39 +123,12 @@
 
 	void *userdata;
 	
-#ifdef RE_RAY_COUNTER
-	RayCounter *count;
+#ifdef RE_RAYCOUNTER
+	RayCounter *raycounter;
 #endif
 	
 };
 
-#ifdef RE_RAYCOUNTER
-
-struct RayCounter
-{
-
-	struct
-	{
-		unsigned long long test, hit;
-		
-	} intersect_rayface, raycast;
-	
-	unsigned long long rayshadow_last_hit_optimization;
-};
-
-void RE_RC_INIT (RayCounter *rc);
-void RE_RC_MERGE(RayCounter *rc, RayCounter *tmp);
-#define RE_RC_COUNT(var) (var)++
-
-#else
-
-#define RE_RC_INIT(rc)
-#define RE_RC_MERGE(dest,src)
-#define	RE_RC_COUNT(var)
-	
-#endif
-
-
 /* ray types */
 #define RE_RAY_SHADOW 0
 #define RE_RAY_MIRROR 1

Modified: branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_shader_ext.h
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_shader_ext.h	2009-07-06 12:24:09 UTC (rev 21384)
+++ branches/soc-2009-jaguarandi/source/blender/render/extern/include/RE_shader_ext.h	2009-07-06 13:27:40 UTC (rev 21385)
@@ -30,6 +30,7 @@
 #ifndef RE_SHADER_EXT_H
 #define RE_SHADER_EXT_H
 
+#include "RE_raytrace.h" /* For RE_RAYCOUNTER */
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
 /* this include is for shading and texture exports            */
 /* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
@@ -57,6 +58,7 @@
 	float nor[3];
 	float rad[3];
 	float winspeed[4];
+	float rayhits[4];
 } ShadeResult;
 
 /* only here for quick copy */
@@ -178,6 +180,10 @@
 	struct Group *light_override;
 	struct Material *mat_override;
 	
+#ifdef RE_RAYCOUNTER
+	RayCounter raycounter;
+#endif
+	
 } ShadeInput;
 
 

Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/pipeline.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/pipeline.c	2009-07-06 12:24:09 UTC (rev 21384)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/pipeline.c	2009-07-06 13:27:40 UTC (rev 21385)
@@ -347,6 +347,13 @@
 		if(channel==-1) return "Mist";
 		return "Mist.Z";
 	}
+	if(passtype == SCE_PASS_RAYHITS)
+	{
+		if(channel==-1) return "Rayhits";
+		if(channel==0) return "Rayhits.R";
+		if(channel==1) return "Rayhits.G";
+		return "Rayhits.B";
+	}
 	return "Unknown";
 }
 
@@ -398,6 +405,8 @@
 	if(strcmp(str, "Mist")==0)
 		return SCE_PASS_MIST;
 	
+	if(strcmp(str, "RAYHITS")==0)
+		return SCE_PASS_RAYHITS;
 	return 0;
 }
 
@@ -523,7 +532,7 @@
 		rl->lay= srl->lay;
 		rl->lay_zmask= srl->lay_zmask;
 		rl->layflag= srl->layflag;
-		rl->passflag= srl->passflag;
+		rl->passflag= srl->passflag | SCE_PASS_RAYHITS;
 		rl->pass_xor= srl->pass_xor;
 		rl->light_override= srl->light_override;
 		rl->mat_override= srl->mat_override;
@@ -565,6 +574,8 @@
 			render_layer_add_pass(rr, rl, 1, SCE_PASS_INDEXOB);
 		if(srl->passflag  & SCE_PASS_MIST)
 			render_layer_add_pass(rr, rl, 1, SCE_PASS_MIST);
+		if(rl->passflag  & SCE_PASS_RAYHITS)
+			render_layer_add_pass(rr, rl, 4, SCE_PASS_RAYHITS);
 		
 	}
 	/* sss, previewrender and envmap don't do layers, so we make a default one */

Modified: branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c
===================================================================
--- branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c	2009-07-06 12:24:09 UTC (rev 21384)
+++ branches/soc-2009-jaguarandi/source/blender/render/intern/source/rayobject.c	2009-07-06 13:27:40 UTC (rev 21385)
@@ -54,10 +54,14 @@
 	float t1z = (bb[isec->bv_index[4]] - isec->start[2]) * isec->idot_axis[2];
 	float t2z = (bb[isec->bv_index[5]] - isec->start[2]) * isec->idot_axis[2];
 
+	RE_RC_COUNT(isec->raycounter->bb.test);
+
 	if(t1x > t2y || t2x < t1y || t1x > t2z || t2x < t1z || t1y > t2z || t2y < t1z) return FLT_MAX;
 	if(t2x < 0.0 || t2y < 0.0 || t2z < 0.0) return FLT_MAX;
 	if(t1x > isec->labda || t1y > isec->labda || t1z > isec->labda) return FLT_MAX;
 
+	RE_RC_COUNT(isec->raycounter->bb.hit);
+
 	dist = t1x;
 	if (t1y > dist) dist = t1y;
     if (t1z > dist) dist = t1z;
@@ -157,7 +161,7 @@
 	if(is->orig.ob == face->ob && is->orig.face == face->face)
 		return 0;
 
-	RE_RC_COUNT(is->count->intersect_rayface.test);
+	RE_RC_COUNT(is->raycounter->faces.test);
 
 	VECCOPY(co1, face->v1);
 	VECCOPY(co2, face->v2);
@@ -276,7 +280,7 @@
 		}
 #endif
 
-		RE_RC_COUNT(is->count->intersect_rayface.hit);
+		RE_RC_COUNT(is->raycounter->faces.hit);
 
 		is->isect= ok;	// wich half of the quad
 		is->labda= labda;
@@ -294,7 +298,7 @@
 int RE_rayobject_raycast(RayObject *r, Isect *isec)
 {
 	int i;
-	RE_RC_COUNT(isec->count->raycast.test);
+	RE_RC_COUNT(isec->raycounter->raycast.test);
 
 	/* Setup vars used on raycast */
 	isec->labda *= Normalize(isec->vec);
@@ -315,15 +319,15 @@
 	/* Last hit heuristic */
 	if(isec->mode==RE_RAY_SHADOW && isec->last_hit && RE_rayobject_intersect(isec->last_hit, isec))
 	{

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list