Added an option to bake AO normalized, without material settings taken

into account. The normalized result can often be easier to integrate
into different materials, e.g. for games.
This commit is contained in:
Brecht Van Lommel
2008-02-19 16:16:16 +00:00
parent 4100861f24
commit 6ea0adb462
4 changed files with 10 additions and 2 deletions

View File

@@ -672,6 +672,7 @@ typedef struct Scene {
#define R_BAKE_CLEAR 1
#define R_BAKE_OSA 2
#define R_BAKE_TO_ACTIVE 4
#define R_BAKE_NORMALIZE_AO 8
/* bake_normal_space */
#define R_BAKE_SPACE_CAMERA 0

View File

@@ -1322,7 +1322,7 @@ static void occ_compute_passes(Render *re, OcclusionTree *tree, int totpass)
static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, float *co, float *n, int thread, int onlyshadow, float *skycol)
{
float nn[3], bn[3], dxyview[3], fac, occ, occlusion, correction;
float nn[3], bn[3], fac, occ, occlusion, correction;
int aocolor;
aocolor= re->wrld.aocolor;
@@ -1351,6 +1351,7 @@ static void sample_occ_tree(Render *re, OcclusionTree *tree, OccFace *exclude, f
}
#if 0
else { /* WO_AOSKYTEX */
float dxyview[3];
bn[0]= -bn[0];
bn[1]= -bn[1];
bn[2]= -bn[2];

View File

@@ -1832,7 +1832,11 @@ static void bake_shade(void *handle, Object *ob, ShadeInput *shi, int quad, int
if(bs->type==RE_BAKE_AO) {
ambient_occlusion(shi);
ambient_occlusion_to_diffuse(shi, shr.combined);
if(R.r.bake_flag & R_BAKE_NORMALIZE_AO)
VECCOPY(shr.combined, shi->ao)
else
ambient_occlusion_to_diffuse(shi, shr.combined);
}
else {
shade_input_set_shade_texco(shi);

View File

@@ -2082,6 +2082,8 @@ static void render_panel_bake(void)
if(G.scene->r.bake_mode == RE_BAKE_NORMALS)
uiDefButS(block, MENU, B_DIFF, "Normal Space %t|Camera %x0|World %x1|Object %x2|Tangent %x3",
10,70,190,20, &G.scene->r.bake_normal_space, 0, 0, 0, 0, "Choose normal space for baking");
else if(G.scene->r.bake_mode == RE_BAKE_AO)
uiDefButBitS(block, TOG, R_BAKE_NORMALIZE_AO, B_DIFF, "Normalized", 10,70,190,20, &G.scene->r.bake_flag, 0.0, 0, 0, 0, "Bake ambient occlusion normalized, without taking into acount material settings");
#if 0
uiBlockBeginAlign(block);