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:
authorTon Roosendaal <ton@blender.org>2006-11-19 17:12:56 +0300
committerTon Roosendaal <ton@blender.org>2006-11-19 17:12:56 +0300
commitc47fa4d0ecefea3f32448cb89610a4cc28aac2bb (patch)
treeba3f59c3bfd5415de4480138fd383d651a56f13f /source/blender/blenkernel
parent204f6066a9c9355aea28bd3092a74d12a52c7869 (diff)
Long waited feature: Render Baking
Here's the full release log with example file. http://www.blender3d.org/cms/Render_Baking.827.0.html For people who don't read docs; just press ALT+CTRL+B on a Mesh with texture faces! Todos: - maybe some filter options extra? - Make normal maps in Tangent space
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/bad_level_call_stubs/stubs.c2
-rw-r--r--source/blender/blenkernel/intern/displist.c30
2 files changed, 22 insertions, 10 deletions
diff --git a/source/blender/blenkernel/bad_level_call_stubs/stubs.c b/source/blender/blenkernel/bad_level_call_stubs/stubs.c
index 18b59a75133..824c1566100 100644
--- a/source/blender/blenkernel/bad_level_call_stubs/stubs.c
+++ b/source/blender/blenkernel/bad_level_call_stubs/stubs.c
@@ -240,7 +240,7 @@ void RE_FreeRender(Render *re) {}
void RE_shade_external(Render *re, ShadeInput *shi, ShadeResult *shr) {}
void RE_DataBase_GetView(Render *re, float mat[][4]) {}
struct Render *RE_NewRender(const char *name) {return (struct Render *)NULL;}
-void RE_Database_Shaded(struct Render *re, struct Scene *scene) {};
+void RE_Database_Baking(struct Render *re, struct Scene *scene, int make_faces) {};
/* node_composite.c */
void RE_zbuf_accumulate_vecblur(struct NodeBlurData *nd, int xsize, int ysize, float *newrect, float *imgrect, float *vecbufrect, float *zbufrect) {}
diff --git a/source/blender/blenkernel/intern/displist.c b/source/blender/blenkernel/intern/displist.c
index 4ac3ea2aac2..5e3439da6bf 100644
--- a/source/blender/blenkernel/intern/displist.c
+++ b/source/blender/blenkernel/intern/displist.c
@@ -377,7 +377,7 @@ static Render *fastshade_get_render(void)
if(re==NULL) {
re= RE_NewRender("_Shade View_");
- RE_Database_Shaded(re, G.scene);
+ RE_Database_Baking(re, G.scene, 0); /* 0= no faces */
}
return re;
}
@@ -393,7 +393,7 @@ void fastshade_free_render(void)
}
}
-static void fastshade(float *co, float *nor, float *orco, Material *ma, char *col1, char *col2, char *vertcol)
+static void fastshade(float *co, float *nor, float *orco, float *uv, Material *ma, char *col1, char *col2, char *vertcol)
{
ShadeResult shr;
int a;
@@ -409,6 +409,7 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
shi.vn[1]= -nor[1];
shi.vn[2]= -nor[2];
VECCOPY(shi.vno, shi.vn);
+ VECCOPY(shi.facenor, shi.vn);
if(ma->texco) {
VECCOPY(shi.lo, orco);
@@ -423,7 +424,13 @@ static void fastshade(float *co, float *nor, float *orco, Material *ma, char *co
VECCOPY(shi.sticky, shi.lo);
}
if(ma->texco & TEXCO_UV) {
- VECCOPY(shi.uv, shi.lo);
+ if(uv) {
+ shi.uv[0]= 2.0f*uv[0]-1.0f;
+ shi.uv[1]= 2.0f*uv[1]-1.0f;
+ }
+ else {
+ VECCOPY(shi.uv, shi.lo);
+ }
}
if(ma->texco & TEXCO_OBJECT) {
VECCOPY(shi.co, shi.lo);
@@ -567,11 +574,12 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
for (i=0; i<dlm->totface; i++) {
MFace *mf= &dlm->mface[i];
+ TFace *tface= dlm->tface?&dlm->tface[i]:NULL;
+ Material *ma= give_current_material(ob, mf->mat_nr+1);
int j, vidx[4], nverts= mf->v4?4:3;
unsigned char *col1base= (unsigned char*) &col1[i*4];
unsigned char *col2base= (unsigned char*) (col2?&col2[i*4]:NULL);
unsigned char *mcolbase;
- Material *ma= give_current_material(ob, mf->mat_nr+1);
float nor[3], n1[3];
if(ma==NULL) ma= &defmaterial;
@@ -609,10 +617,14 @@ static void mesh_create_shadedColors(Render *re, Object *ob, int onlyForMesh, un
char *col2= (char*)(col2base?&col2base[j*4]:NULL);
char *mcol= (char*)(mcolbase?&mcolbase[j*4]:NULL);
float *vn = (mf->flag & ME_SMOOTH)?&vnors[3*vidx[j]]:n1;
-
+ float *uv= tface?tface->uv[j]:NULL;
+
VECCOPY(vec, mv->co);
Mat4MulVecfl(mat, vec);
- fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, ma, col1, col2, mcol);
+ vec[0]+= 0.001*vn[0];
+ vec[1]+= 0.001*vn[1];
+ vec[2]+= 0.001*vn[2];
+ fastshade(vec, vn, orco?&orco[vidx[j]*3]:mv->co, uv, ma, col1, col2, mcol);
}
}
MEM_freeN(vnors);
@@ -705,7 +717,7 @@ void shadeDispList(Base *base)
VECCOPY(vec, fp);
Mat4MulVecfl(mat, vec);
- fastshade(vec, n1, fp, ma, (char *)col1, 0, 0);
+ fastshade(vec, n1, fp, NULL, ma, (char *)col1, NULL, NULL);
fp+= 3; col1++;
}
@@ -726,7 +738,7 @@ void shadeDispList(Base *base)
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
Normalise(n1);
- fastshade(vec, n1, fp, ma, (char *)col1, 0, 0);
+ fastshade(vec, n1, fp, NULL, ma, (char *)col1, NULL, NULL);
fp+= 3; nor+= 3; col1++;
}
@@ -764,7 +776,7 @@ void shadeDispList(Base *base)
n1[2]= imat[2][0]*nor[0]+imat[2][1]*nor[1]+imat[2][2]*nor[2];
Normalise(n1);
- fastshade(vec, n1, fp, ma, (char *)col1, 0, 0);
+ fastshade(vec, n1, fp, NULL, ma, (char *)col1, NULL, NULL);
fp+= 3; col1++; nor+= 3;
}