Page MenuHome

bake-more.diff

Authored By
Frank Richter (res)
Nov 13 2013, 1:15 PM
Size
8 KB
Subscribers
None

bake-more.diff

Index: source/blender/render/intern/source/convertblender.c
===================================================================
--- source/blender/render/intern/source/convertblender.c (revision 12010)
+++ source/blender/render/intern/source/convertblender.c (working copy)
@@ -4028,12 +4028,12 @@
Object *obd= dob->ob;
if(obd->type==OB_LAMP) {
- if( ELEM(type, RE_BAKE_LIGHT, RE_BAKE_ALL) ) {
+ if( ELEM3(type, RE_BAKE_LIGHT, RE_BAKE_ALL, RE_BAKE_LIGHTING) ) {
Mat4CpyMat4(obd->obmat, dob->mat);
init_render_object(re, obd, ob, dob->index, 0);
}
}
- else if( ELEM(type, RE_BAKE_AO, RE_BAKE_ALL) ) {
+ else if( ELEM4(type, RE_BAKE_AO, RE_BAKE_ALL, RE_BAKE_LIGHTING, RE_BAKE_AO_NRM) ) {
if((base->flag & SELECT)==0) {
Mat4CpyMat4(obd->obmat, dob->mat);
init_render_object(re, obd, ob, dob->index, 0);
@@ -4044,7 +4044,7 @@
}
else {
if(ob->type==OB_LAMP) {
- if( ELEM(type, RE_BAKE_LIGHT, RE_BAKE_ALL) )
+ if( ELEM3(type, RE_BAKE_LIGHT, RE_BAKE_ALL, RE_BAKE_LIGHTING) )
init_render_object(re, ob, NULL, 0, 0);
}
else if(type!=RE_BAKE_LIGHT) {
Index: source/blender/render/intern/source/rendercore.c
===================================================================
--- source/blender/render/intern/source/rendercore.c (revision 12010)
+++ source/blender/render/intern/source/rendercore.c (working copy)
@@ -1717,9 +1717,20 @@
memcpy(&shi->r, &shi->mat->r, 23*sizeof(float)); // note, keep this synced with render_types.h
shi->har= shi->mat->har;
- if(bs->type==RE_BAKE_AO) {
+ if(bs->type==RE_BAKE_LIGHTING) {
+ shi->passflag = SCE_PASS_SHADOW|SCE_PASS_AO;
+ }
+
+ if((bs->type==RE_BAKE_AO)||(bs->type==RE_BAKE_AO_NRM)) {
+ float old_ao_energy = R.wrld.aoenergy;
+ if (bs->type==RE_BAKE_AO_NRM)
+ {
+ R.wrld.aoenergy = 1.0f;
+ shi->mat->amb = 1.0f;
+ }
ambient_occlusion(shi);
ambient_occlusion_to_diffuse(shi, shr.combined);
+ if (bs->type==RE_BAKE_AO_NRM) R.wrld.aoenergy = old_ao_energy;
}
else {
@@ -1745,6 +1756,11 @@
shr.combined[2]= shi->b;
}
}
+ if(bs->type==RE_BAKE_LIGHTING) {
+ shr.combined[0] *= R.r.bake_lightscale;
+ shr.combined[1] *= R.r.bake_lightscale;
+ shr.combined[2] *= R.r.bake_lightscale;
+ }
if(bs->rect) {
char *col= (char *)(bs->rect + bs->rectx*y + x);
Index: source/blender/render/extern/include/RE_pipeline.h
===================================================================
--- source/blender/render/extern/include/RE_pipeline.h (revision 12010)
+++ source/blender/render/extern/include/RE_pipeline.h (working copy)
@@ -209,6 +209,8 @@
#define RE_BAKE_AO 2
#define RE_BAKE_NORMALS 3
#define RE_BAKE_TEXTURE 4
+#define RE_BAKE_LIGHTING 5
+#define RE_BAKE_AO_NRM 6
void RE_Database_Baking(struct Render *re, struct Scene *scene, int type);
void RE_DataBase_GetView(struct Render *re, float mat[][4]);
Index: source/blender/blenkernel/intern/scene.c
===================================================================
--- source/blender/blenkernel/intern/scene.c (revision 12010)
+++ source/blender/blenkernel/intern/scene.c (working copy)
@@ -203,6 +203,7 @@
sce->r.bake_filter= 2;
sce->r.bake_osa= 5;
sce->r.bake_flag= R_BAKE_CLEAR;
+ sce->r.bake_lightscale= 1.0;
sce->r.xplay= 640;
sce->r.yplay= 480;
Index: source/blender/makesdna/DNA_scene_types.h
===================================================================
--- source/blender/makesdna/DNA_scene_types.h (revision 12010)
+++ source/blender/makesdna/DNA_scene_types.h (working copy)
@@ -250,7 +250,6 @@
/* information on different layers to be rendered */
ListBase layers;
short actlay, pad;
- int pad2;
/**
* Value used to define filter size for all filter options */
@@ -264,6 +263,7 @@
/* Bake Render options */
short bake_osa, bake_filter, bake_mode, bake_flag;
+ float bake_lightscale;
/* yafray: global panel params. TODO: move elsewhere */
short GIquality, GIcache, GImethod, GIphotons, GIdirect;
Index: source/blender/src/meshtools.c
===================================================================
--- source/blender/src/meshtools.c (revision 12010)
+++ source/blender/src/meshtools.c (working copy)
@@ -868,7 +868,7 @@
{
short event;
- event= pupmenu("Bake Selected Meshes %t|Full Render %x1|Ambient Occlusion %x2|Normals %x3|Texture Only %x4");
+ event= pupmenu("Bake Selected Meshes %t|Full Render %x1|Lighting %x2|Ambient Occlusion %x3|Ambient Occlusion (Normalized) %x4|Normals %x5|Texture Only %x6");
objects_bake_render(event);
}
@@ -877,15 +877,26 @@
void objects_bake_render(short event)
{
short prev_r_raytrace= 0, prev_wo_amb_occ= 0;
+ short bakemode;
- if(event==0) event= G.scene->r.bake_mode;
+ switch (event)
+ {
+ case 0: bakemode= G.scene->r.bake_mode; break;
+ case 1: bakemode= RE_BAKE_ALL; break;
+ case 2: bakemode= RE_BAKE_LIGHTING; break;
+ case 3: bakemode= RE_BAKE_AO; break;
+ case 4: bakemode= RE_BAKE_AO_NRM; break;
+ case 5: bakemode= RE_BAKE_NORMALS; break;
+ default:
+ case 6: bakemode= RE_BAKE_TEXTURE; break;
+ }
if(G.scene->r.renderer!=R_INTERN) {
error("Bake only supported for Internal Renderer");
return;
}
- if(event>0) {
+ if(event>=0) {
Render *re= RE_NewRender("_Bake View_");
ScrArea *area= biggest_image_area();
ListBase threads;
@@ -894,12 +905,7 @@
if(sculptmode) set_sculptmode();
- if(event==1) event= RE_BAKE_ALL;
- else if(event==2) event= RE_BAKE_AO;
- else if(event==3) event= RE_BAKE_NORMALS;
- else event= RE_BAKE_TEXTURE;
-
- if(event==RE_BAKE_AO) {
+ if((bakemode==RE_BAKE_AO)||(bakemode==RE_BAKE_AO_NRM)) {
if(G.scene->world==NULL) {
error("No world set up");
return;
@@ -918,13 +924,13 @@
g_break= 0;
G.afbreek= 0; /* blender_test_break uses this global */
- RE_Database_Baking(re, G.scene, event);
+ RE_Database_Baking(re, G.scene, bakemode);
/* baking itself is threaded, cannot use test_break in threads. we also update optional imagewindow */
BLI_init_threads(&threads, do_bake_render, 1);
bkr.re= re;
- bkr.event= event;
+ bkr.event= bakemode;
bkr.ready= 0;
BLI_insert_thread(&threads, &bkr);
Index: source/blender/src/buttons_scene.c
===================================================================
--- source/blender/src/buttons_scene.c (revision 12010)
+++ source/blender/src/buttons_scene.c (working copy)
@@ -1253,14 +1253,18 @@
#endif
uiBlockBeginAlign(block);
uiDefButS(block, ROW,B_DIFF,"Full Render", 210,170,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_ALL, 0, 0, "");
- uiDefButS(block, ROW,B_DIFF,"Ambient Occlusion",210,150,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_AO, 0, 0, "");
- uiDefButS(block, ROW,B_DIFF,"Normals", 210,130,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_NORMALS, 0, 0, "");
- uiDefButS(block, ROW,B_DIFF,"Textures", 210,110,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_TEXTURE, 0, 0, "");
+ uiDefButS(block, ROW,B_DIFF,"Lighting", 210,150,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_LIGHTING, 0, 0, "");
+ uiDefButS(block, ROW,B_DIFF,"Ambient Occlusion",210,130,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_AO, 0, 0, "");
+ uiDefButS(block, ROW,B_DIFF,"Amb. Occl. (Norm.)",210,110,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_AO_NRM, 0, 0, "");
+ uiDefButS(block, ROW,B_DIFF,"Normals", 210, 90,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_NORMALS, 0, 0, "");
+ uiDefButS(block, ROW,B_DIFF,"Textures", 210, 70,120,20,&G.scene->r.bake_mode, 1.0, RE_BAKE_TEXTURE, 0, 0, "");
uiBlockEndAlign(block);
- uiDefButBitS(block, TOG, R_BAKE_CLEAR, B_DIFF, "Clear", 210,80,120,20,&G.scene->r.bake_flag, 0.0, 0, 0, 0, "Clear Images before baking");
+ uiDefButBitS(block, TOG, R_BAKE_CLEAR, B_DIFF, "Clear", 210,40,120,20,&G.scene->r.bake_flag, 0.0, 0, 0, 0, "Clear Images before baking");
- uiDefButS(block, NUM, B_DIFF,"Margin:", 210,50,120,20,&G.scene->r.bake_filter, 0.0, 32.0, 0, 0, "Amount of pixels to extend the baked result with, as post process filter");
+ uiDefButS(block, NUM, B_DIFF,"Margin:", 210,10,120,20,&G.scene->r.bake_filter, 0.0, 32.0, 0, 0, "Amount of pixels to extend the baked result with, as post process filter");
+ uiDefButF(block, NUMSLI, B_DIFF,"Light:", 10,10,190,20,&G.scene->r.bake_lightscale,0.0, 1.0, 0, 0, "Baked lighting scaling factor");
+
}
static void render_panel_render(void)

File Metadata

Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
68/a4/d9820519a074c861009df9e6e9f5

Event Timeline