forked from bartvdbraak/blender
Apricot feature, thats fit for trunk.
Baking would split non-planer quads in an unpredictable way, which is fine for rending but game engines often use a fixed order (0,1,2), (0,2,3) or (1,2,3) (1,3,0). Added an option to use a fixed order when baking.
This commit is contained in:
parent
172fe6ed2f
commit
f2407fec55
@ -274,7 +274,7 @@ typedef struct RenderData {
|
|||||||
|
|
||||||
/* Bake Render options */
|
/* Bake Render options */
|
||||||
short bake_osa, bake_filter, bake_mode, bake_flag;
|
short bake_osa, bake_filter, bake_mode, bake_flag;
|
||||||
short bake_normal_space, bpad;
|
short bake_normal_space, bake_quad_split;
|
||||||
float bake_maxdist, bake_biasdist, bake_pad;
|
float bake_maxdist, bake_biasdist, bake_pad;
|
||||||
|
|
||||||
/* yafray: global panel params. TODO: move elsewhere */
|
/* yafray: global panel params. TODO: move elsewhere */
|
||||||
|
@ -499,6 +499,7 @@ typedef struct LampRen {
|
|||||||
#define R_NEED_TANGENT 32
|
#define R_NEED_TANGENT 32
|
||||||
#define R_SKIP_MULTIRES 64
|
#define R_SKIP_MULTIRES 64
|
||||||
#define R_BAKE_TRACE 128
|
#define R_BAKE_TRACE 128
|
||||||
|
#define R_BAKING 256
|
||||||
|
|
||||||
/* vlakren->flag (vlak = face in dutch) char!!! */
|
/* vlakren->flag (vlak = face in dutch) char!!! */
|
||||||
#define R_SMOOTH 1
|
#define R_SMOOTH 1
|
||||||
|
@ -3935,7 +3935,7 @@ static void set_fullsample_flag(Render *re, ObjectRen *obr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_non_flat_quads(ObjectRen *obr)
|
static void check_non_flat_quads(ObjectRen *obr, int quad_flip)
|
||||||
{
|
{
|
||||||
VlakRen *vlr, *vlr1;
|
VlakRen *vlr, *vlr1;
|
||||||
VertRen *v1, *v2, *v3, *v4;
|
VertRen *v1, *v2, *v3, *v4;
|
||||||
@ -3997,11 +3997,13 @@ static void check_non_flat_quads(ObjectRen *obr)
|
|||||||
xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2];
|
xn= nor[0]*vlr->n[0] + nor[1]*vlr->n[1] + nor[2]*vlr->n[2];
|
||||||
|
|
||||||
if(ABS(xn) < 0.999995 ) { // checked on noisy fractal grid
|
if(ABS(xn) < 0.999995 ) { // checked on noisy fractal grid
|
||||||
|
|
||||||
float d1, d2;
|
float d1, d2;
|
||||||
|
|
||||||
vlr1= RE_vlakren_copy(obr, vlr);
|
vlr1= RE_vlakren_copy(obr, vlr);
|
||||||
vlr1->flag |= R_FACE_SPLIT;
|
vlr1->flag |= R_FACE_SPLIT;
|
||||||
|
|
||||||
|
if (quad_flip==0) { /* nonzero quad_flip is used to force dividing one way */
|
||||||
/* split direction based on vnorms */
|
/* split direction based on vnorms */
|
||||||
CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, nor);
|
CalcNormFloat(vlr->v1->co, vlr->v2->co, vlr->v3->co, nor);
|
||||||
d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2];
|
d1= nor[0]*vlr->v1->n[0] + nor[1]*vlr->v1->n[1] + nor[2]*vlr->v1->n[2];
|
||||||
@ -4011,6 +4013,11 @@ static void check_non_flat_quads(ObjectRen *obr)
|
|||||||
|
|
||||||
if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24;
|
if( fabs(d1) < fabs(d2) ) vlr->flag |= R_DIVIDE_24;
|
||||||
else vlr->flag &= ~R_DIVIDE_24;
|
else vlr->flag &= ~R_DIVIDE_24;
|
||||||
|
} else if (quad_flip==1) {
|
||||||
|
vlr->flag &= ~R_DIVIDE_24;
|
||||||
|
} else { /* quad_flip == 3 */
|
||||||
|
vlr->flag |= R_DIVIDE_24;
|
||||||
|
}
|
||||||
|
|
||||||
/* new vertex pointers */
|
/* new vertex pointers */
|
||||||
if (vlr->flag & R_DIVIDE_24) {
|
if (vlr->flag & R_DIVIDE_24) {
|
||||||
@ -4065,7 +4072,13 @@ static void finalize_render_object(Render *re, ObjectRen *obr, int timeoffset)
|
|||||||
if((re->r.mode & R_RAYTRACE) && (re->r.mode & R_SHADOW))
|
if((re->r.mode & R_RAYTRACE) && (re->r.mode & R_SHADOW))
|
||||||
set_phong_threshold(obr);
|
set_phong_threshold(obr);
|
||||||
|
|
||||||
check_non_flat_quads(obr);
|
if (re->flag & R_BAKING) {
|
||||||
|
/* Baking lets us define a quad split order */
|
||||||
|
check_non_flat_quads(obr, re->r.bake_quad_split);
|
||||||
|
} else {
|
||||||
|
check_non_flat_quads(obr, 0);
|
||||||
|
}
|
||||||
|
|
||||||
set_fullsample_flag(re, obr);
|
set_fullsample_flag(re, obr);
|
||||||
|
|
||||||
/* compute bounding boxes for clipping */
|
/* compute bounding boxes for clipping */
|
||||||
@ -5421,6 +5434,7 @@ void RE_Database_Baking(Render *re, Scene *scene, int type, Object *actob)
|
|||||||
RE_init_threadcount(re);
|
RE_init_threadcount(re);
|
||||||
|
|
||||||
re->flag |= R_GLOB_NOPUNOFLIP;
|
re->flag |= R_GLOB_NOPUNOFLIP;
|
||||||
|
re->flag |= R_BAKING;
|
||||||
re->excludeob= actob;
|
re->excludeob= actob;
|
||||||
if(type == RE_BAKE_LIGHT)
|
if(type == RE_BAKE_LIGHT)
|
||||||
re->flag |= R_SKIP_MULTIRES;
|
re->flag |= R_SKIP_MULTIRES;
|
||||||
|
@ -2150,6 +2150,10 @@ static void render_panel_bake(void)
|
|||||||
"Normalized displacement value to fit the 'Dist' range"
|
"Normalized displacement value to fit the 'Dist' range"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uiDefButS(block, MENU, B_NOP, "Quad Split Order%t|Quad Split Auto%x0|Quad Split A (0,1,2) (0,2,3)%x1|Quad Split B (1,2,3) (1,3,0)%x2",
|
||||||
|
10,30,190,20, &G.scene->r.bake_quad_split, 0, 0, 0, 0, "Method to divide quads (use A or B for external applications that use a fixed order)");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
uiBlockBeginAlign(block);
|
uiBlockBeginAlign(block);
|
||||||
uiDefButBitS(block, TOG, R_BAKE_OSA, B_DIFF, "OSA", 10,120,190,20, &G.scene->r.bake_flag, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
|
uiDefButBitS(block, TOG, R_BAKE_OSA, B_DIFF, "OSA", 10,120,190,20, &G.scene->r.bake_flag, 0, 0, 0, 0, "Enables Oversampling (Anti-aliasing)");
|
||||||
|
Loading…
Reference in New Issue
Block a user