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:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2007-12-15 23:41:45 +0300
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2007-12-15 23:41:45 +0300
commit460dd7a7bbd43526e684bde96fcb6098676afdc8 (patch)
tree84f48511c9fbc9cf3bef84e139b22191cd581e1f /source/blender/render/extern
parentdbc8e1e883c136ffa69e7216370bc5100fad5970 (diff)
Render Instancing
================= Big commit, but little user visible changes. - Dupliverts and duplifaces are now rendered as instances, instead of storing all of the geometry for each dupli, now an instance is created with a matrix transform refering to the source object. This should allow us to render tree leaves more memory efficient. - Radiosity and to some degree raytracing of such objects is not really efficient still. For radiosity this is fundamentally hard to solve, but raytracing an octree could be created for each object, but the current octree code with it's fixed size doesn't allow this efficiently. - The regression tests survived, but with I expect that some bugs will pop up .. hopefully not too many :). Implementation Notes ==================== - Dupligroups and linked meshes are not rendered as instances yet, since they can in fact be different due to various reasons, instancing of these types of duplis that are the same can be added for them at a later point. - Each ObjectRen now stores it's own database, instead of there being one big databases of faces, verts, .. . Which objects that are actually rendered are defined by the list of ObjectRenInstances, which all refer to an ObjectRen. - Homogeneous coordinatess and clipping is now not stored in vertices anymore, but instead computed on the fly. This couldn't work for instances. That does mean some extra computation has to be done, but memory lookups can be slow too, and this saves some memory. Overall I didn't find a significant speed impact. - OSA rendering for solid and ztransp now is different. Instead of e.g. going 8 times over the databases times and rendering the z-buffer, it now goes over the database once and renders each polygon 8 times. That was necessary to keep instances efficient, and can also give some performance improvement without instances. - There was already instancing support in the yafray export code, now it uses Blender's render instances for export. - UV and color layer storage in the render was a bit messy before, now should be easier to understand. - convertblender.c was reorganized somewhat. Regular render, speedvector and baking now use a single function to create the database, previously there was code duplicated for it. - Some of these changes were done with future multithreading of scene and shadow buffer creation in mind, though especially for scene creation much work remains to be done to make it threadsafe, since it also involves a lot of code from blenkernel, and there is an ugly conflict with the way dupli groups work here .. though in the render code itself it's almost there.
Diffstat (limited to 'source/blender/render/extern')
-rw-r--r--source/blender/render/extern/include/RE_raytrace.h26
-rw-r--r--source/blender/render/extern/include/RE_shader_ext.h8
2 files changed, 30 insertions, 4 deletions
diff --git a/source/blender/render/extern/include/RE_raytrace.h b/source/blender/render/extern/include/RE_raytrace.h
index d20e3130fa4..39bf2be4256 100644
--- a/source/blender/render/extern/include/RE_raytrace.h
+++ b/source/blender/render/extern/include/RE_raytrace.h
@@ -41,6 +41,19 @@ typedef void RayTree;
/* abstraction of face type */
typedef void RayFace;
+/* object numbers above this are transformed */
+#define RE_RAY_TRANSFORM_OFFS 0x8000000
+
+/* convert from pointer to index in array and back, with offset if the
+ * instance is transformed */
+#define RAY_OBJECT_SET(re, obi) \
+ ((obi == NULL)? 0: \
+ ((obi - (re)->objectinstance) + ((obi->flag & R_TRANSFORMED)? RE_RAY_TRANSFORM_OFFS: 0)))
+
+#define RAY_OBJECT_GET(re, i) \
+ ((re)->objectinstance + ((i >= RE_RAY_TRANSFORM_OFFS)? i-RE_RAY_TRANSFORM_OFFS: i))
+
+
/* struct for intersection data */
typedef struct Isect {
float start[3]; /* start+vec = end, in ray_tree_intersect */
@@ -50,8 +63,11 @@ typedef struct Isect {
float labda, u, v; /* distance to hitpoint, uv weights */
RayFace *face; /* face is where to intersect with */
+ int ob;
RayFace *faceorig; /* start face */
+ int oborig;
RayFace *face_last; /* for shadow optimize, last intersected face */
+ int ob_last;
short isect; /* which half of quad */
short mode; /* RE_RAYSHADOW, RE_RAYMIRROR, RE_RAYSHADOW_TRA */
@@ -62,6 +78,7 @@ typedef struct Isect {
/* octree only */
RayFace *facecontr;
+ int obcontr;
float ddalabda;
short faceisect; /* flag if facecontr was done or not */
@@ -73,18 +90,21 @@ typedef struct Isect {
typedef void (*RayCoordsFunc)(RayFace *face,
float **v1, float **v2, float **v3, float **v4);
typedef int (*RayCheckFunc)(Isect *is, RayFace *face);
+typedef float *(*RayObjectTransformFunc)(void *userdata, int ob);
/* tree building and freeing */
RayTree *RE_ray_tree_create(int ocres, int totface, float *min, float *max,
- RayCoordsFunc coordfunc, RayCheckFunc checkfunc);
-void RE_ray_tree_add_face(RayTree *tree, RayFace *face);
+ RayCoordsFunc coordfunc, RayCheckFunc checkfunc,
+ RayObjectTransformFunc transformfunc, void *userdata);
+void RE_ray_tree_add_face(RayTree *tree, int ob, RayFace *face);
void RE_ray_tree_done(RayTree *tree);
void RE_ray_tree_free(RayTree *tree);
/* intersection with full tree and single face */
int RE_ray_tree_intersect(RayTree *tree, Isect *is);
int RE_ray_tree_intersect_check(RayTree *tree, Isect *is, RayCheckFunc check);
-int RE_ray_face_intersection(Isect *is, RayCoordsFunc coordsfunc);
+int RE_ray_face_intersection(Isect *is, RayObjectTransformFunc transformfunc,
+ RayCoordsFunc coordsfunc);
/* retrieve the diameter of the tree structure, for setting intersection
end distance */
diff --git a/source/blender/render/extern/include/RE_shader_ext.h b/source/blender/render/extern/include/RE_shader_ext.h
index 8a4f6bb2ec8..5b81052f5d2 100644
--- a/source/blender/render/extern/include/RE_shader_ext.h
+++ b/source/blender/render/extern/include/RE_shader_ext.h
@@ -64,8 +64,11 @@ struct ShadeInputCopy {
struct Material *mat;
struct VlakRen *vlr;
+ struct ObjectInstanceRen *obi;
+ struct ObjectRen *obr;
int facenr;
float facenor[3]; /* copy from face */
+ short flippednor; /* is facenor flipped? */
struct VertRen *v1, *v2, *v3; /* vertices can be in any order for quads... */
short i1, i2, i3; /* original vertex indices */
short puno;
@@ -93,8 +96,11 @@ typedef struct ShadeInput
struct Material *mat;
struct VlakRen *vlr;
+ struct ObjectInstanceRen *obi;
+ struct ObjectRen *obr;
int facenr;
float facenor[3]; /* copy from face */
+ short flippednor; /* is facenor flipped? */
struct VertRen *v1, *v2, *v3; /* vertices can be in any order for quads... */
short i1, i2, i3; /* original vertex indices */
short puno;
@@ -130,7 +136,7 @@ typedef struct ShadeInput
ShadeInputUV uv[8]; /* 8 = MAX_MTFACE */
ShadeInputCol col[8]; /* 8 = MAX_MCOL */
- int totuv, totcol;
+ int totuv, totcol, actuv, actcol;
/* dx/dy OSA coordinates */
float dxco[3], dyco[3];