Solved AO smooth rendering, by introducing a "Bias" value for smoothed
rendered faces. http://www.blender3d.org/cms/Ambient_Occlusion.231.0.html ALso removed prints when allocating new 'face groups' etc, which wasn't informative at all.
This commit is contained in:
parent
d8ca2263c1
commit
0facc2681e
|
@ -96,7 +96,8 @@ World *add_world(char *name)
|
|||
wrld->aodist= 10.0;
|
||||
wrld->aosamp= 5;
|
||||
wrld->aoenergy= 1.0;
|
||||
|
||||
wrld->aobias= 0.05;
|
||||
|
||||
return wrld;
|
||||
}
|
||||
|
||||
|
|
|
@ -4174,7 +4174,10 @@ static void do_versions(Main *main)
|
|||
}
|
||||
|
||||
while(wrld) {
|
||||
if(wrld->aodist==0.0) wrld->aodist= 10.0;
|
||||
if(wrld->aodist==0.0) {
|
||||
wrld->aodist= 10.0;
|
||||
wrld->aobias= 0.05;
|
||||
}
|
||||
if(wrld->aosamp==0.0) wrld->aosamp= 5;
|
||||
if(wrld->aoenergy==0.0) wrld->aoenergy= 1.0;
|
||||
wrld= wrld->id.next;
|
||||
|
|
|
@ -95,7 +95,7 @@ typedef struct World {
|
|||
short dofsta, dofend, dofmin, dofmax;
|
||||
|
||||
/* ambient occlusion */
|
||||
float aodist, aodistfac, aoenergy, pad;
|
||||
float aodist, aodistfac, aoenergy, aobias;
|
||||
short aomode, aosamp, aomix, aocolor;
|
||||
|
||||
int physicsEngine;
|
||||
|
|
|
@ -2071,7 +2071,7 @@ static float *sphere_sampler(int type, int resol, float *nrm)
|
|||
void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
|
||||
{
|
||||
Isect isec;
|
||||
float *vec, *nrm, div, sh=0;
|
||||
float *vec, *nrm, div, bias, sh=0;
|
||||
float maxdist = wrld->aodist;
|
||||
int tot, actual;
|
||||
|
||||
|
@ -2092,7 +2092,16 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
|
|||
R.wrld.zenb= G.scene->world->zenb;
|
||||
}
|
||||
|
||||
nrm= shi->vlr->n;
|
||||
// bias prevents smoothed faces to appear flat
|
||||
if(shi->vlr->flag & R_SMOOTH) {
|
||||
bias= G.scene->world->aobias;
|
||||
nrm= shi->vn;
|
||||
}
|
||||
else {
|
||||
bias= 0.0;
|
||||
nrm= shi->vlr->n;
|
||||
}
|
||||
|
||||
vec= sphere_sampler(wrld->aomode, wrld->aosamp, nrm);
|
||||
|
||||
// warning: since we use full sphere now, and dotproduct is below, we do twice as much
|
||||
|
@ -2101,7 +2110,7 @@ void ray_ao(ShadeInput *shi, World *wrld, float *shadfac)
|
|||
|
||||
while(tot--) {
|
||||
|
||||
if ((vec[0]*nrm[0] + vec[1]*nrm[1] + vec[2]*nrm[2]) > 0.0) {
|
||||
if ((vec[0]*nrm[0] + vec[1]*nrm[1] + vec[2]*nrm[2]) > bias) {
|
||||
|
||||
actual++;
|
||||
|
||||
|
|
|
@ -87,8 +87,8 @@ VertRen *RE_findOrAddVert(int nr)
|
|||
a= nr>>8;
|
||||
|
||||
if (a>=rblovelen){ /* Need to allocate more columns...*/
|
||||
printf("Allocating %i more vert groups. %i total.\n",
|
||||
TABLEINITSIZE, rblovelen+TABLEINITSIZE );
|
||||
// printf("Allocating %i more vert groups. %i total.\n",
|
||||
// TABLEINITSIZE, rblovelen+TABLEINITSIZE );
|
||||
temp=R.blove;
|
||||
R.blove=(VertRen**)MEM_callocN(sizeof(void*)*(rblovelen+TABLEINITSIZE) , "Blove");
|
||||
memcpy(R.blove, temp, rblovelen*sizeof(void*));
|
||||
|
@ -120,8 +120,8 @@ HaloRen *RE_findOrAddHalo(int nr)
|
|||
a= nr>>8;
|
||||
|
||||
if (a>=rblohalen){ /* Need to allocate more columns...*/
|
||||
printf("Allocating %i more halo groups. %i total.\n",
|
||||
TABLEINITSIZE, rblohalen+TABLEINITSIZE );
|
||||
//printf("Allocating %i more halo groups. %i total.\n",
|
||||
// TABLEINITSIZE, rblohalen+TABLEINITSIZE );
|
||||
temp=R.bloha;
|
||||
R.bloha=(HaloRen**)MEM_callocN(sizeof(void*)*(rblohalen+TABLEINITSIZE) , "Blove");
|
||||
memcpy(R.bloha, temp, rblohalen*sizeof(void*));
|
||||
|
@ -154,8 +154,8 @@ VlakRen *RE_findOrAddVlak(int nr)
|
|||
a= nr>>8;
|
||||
|
||||
if (a>=rblovllen){ /* Need to allocate more columns...*/
|
||||
printf("Allocating %i more face groups. %i total.\n",
|
||||
TABLEINITSIZE, rblovllen+TABLEINITSIZE );
|
||||
// printf("Allocating %i more face groups. %i total.\n",
|
||||
// TABLEINITSIZE, rblovllen+TABLEINITSIZE );
|
||||
temp=R.blovl;
|
||||
R.blovl=(VlakRen**)MEM_callocN(sizeof(void*)*(rblovllen+TABLEINITSIZE) , "Blove");
|
||||
memcpy(R.blovl, temp, rblovllen*sizeof(void*));
|
||||
|
|
|
@ -1729,9 +1729,10 @@ static void world_panel_amb_occ(World *wrld)
|
|||
uiDefButS(block, ROW, B_REDR, "Plain", 10, 25, 100, 20, &wrld->aocolor, 2.0, (float)WO_AOPLAIN, 0, 0, "Plain diffuse energy (white)");
|
||||
uiDefButS(block, ROW, B_REDR, "Sky Color", 110, 25, 100, 20, &wrld->aocolor, 2.0, (float)WO_AOSKYCOL, 0, 0, "Use horizon and zenith color for diffuse energy");
|
||||
uiDefButS(block, ROW, B_REDR, "Sky Texture", 210, 25, 100, 20, &wrld->aocolor, 2.0, (float)WO_AOSKYTEX, 0, 0, "Does full Sky texture render for diffuse energy");
|
||||
uiBlockEndAlign(block);
|
||||
|
||||
uiDefButF(block, NUMSLI, 0, "Energy:", 10, 0, 300, 19, &wrld->aoenergy, 0.01, 3.0, 100, 0, "Sets global energy scale for AO");
|
||||
uiBlockBeginAlign(block);
|
||||
uiDefButF(block, NUMSLI, 0, "Energy:", 10, 0, 150, 19, &wrld->aoenergy, 0.01, 3.0, 100, 0, "Sets global energy scale for AO");
|
||||
uiDefButF(block, NUMSLI, 0, "Bias:", 160, 0, 150, 19, &wrld->aobias, 0.0, 0.5, 10, 0, "Sets bias to prevent smoothed faces to show banding (in radians)");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2892,7 +2893,6 @@ void texture_panels()
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
/* old popup.. too hackish, should be fixed once (ton) */
|
||||
void clever_numbuts_buts()
|
||||
{
|
||||
|
@ -2906,22 +2906,10 @@ void clever_numbuts_buts()
|
|||
static char hexze[8];
|
||||
int rgb[3];
|
||||
|
||||
switch (G.buts->mainb){
|
||||
case BUTS_FPAINT:
|
||||
|
||||
sprintf(hexrgb, "%02X%02X%02X", (int)(Gvp.r*255), (int)(Gvp.g*255), (int)(Gvp.b*255));
|
||||
|
||||
add_numbut(0, TEX, "RGB:", 0, 6, hexrgb, "HTML Hex value for the RGB color");
|
||||
do_clever_numbuts("Vertex Paint RGB Hex Value", 1, REDRAW);
|
||||
|
||||
/* Assign the new hex value */
|
||||
sscanf(hexrgb, "%02X%02X%02X", &rgb[0], &rgb[1], &rgb[2]);
|
||||
Gvp.r= (rgb[0]/255.0 >= 0.0 && rgb[0]/255.0 <= 1.0 ? rgb[0]/255.0 : 0.0) ;
|
||||
Gvp.g = (rgb[1]/255.0 >= 0.0 && rgb[1]/255.0 <= 1.0 ? rgb[1]/255.0 : 0.0) ;
|
||||
Gvp.b = (rgb[2]/255.0 >= 0.0 && rgb[2]/255.0 <= 1.0 ? rgb[2]/255.0 : 0.0) ;
|
||||
|
||||
break;
|
||||
case BUTS_LAMP:
|
||||
if(G.buts->mainb!= CONTEXT_SHADING) return;
|
||||
|
||||
switch (G.buts->tab[CONTEXT_SHADING]) {
|
||||
case TAB_SHADING_LAMP:
|
||||
la= G.buts->lockpoin;
|
||||
if (la){
|
||||
sprintf(hexrgb, "%02X%02X%02X", (int)(la->r*255), (int)(la->g*255), (int)(la->b*255));
|
||||
|
@ -2934,7 +2922,7 @@ void clever_numbuts_buts()
|
|||
BIF_preview_changed(G.buts);
|
||||
}
|
||||
break;
|
||||
case BUTS_WORLD:
|
||||
case TAB_SHADING_WORLD:
|
||||
wo= G.buts->lockpoin;
|
||||
if (wo){
|
||||
sprintf(hexho, "%02X%02X%02X", (int)(wo->horr*255), (int)(wo->horg*255), (int)(wo->horb*255));
|
||||
|
@ -2955,7 +2943,7 @@ void clever_numbuts_buts()
|
|||
|
||||
}
|
||||
break;
|
||||
case BUTS_MAT:
|
||||
case TAB_SHADING_MAT:
|
||||
|
||||
ma= G.buts->lockpoin;
|
||||
|
||||
|
@ -2990,7 +2978,7 @@ void clever_numbuts_buts()
|
|||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
void radio_panels()
|
||||
{
|
||||
|
|
|
@ -1409,26 +1409,31 @@ void clever_numbuts(void)
|
|||
{
|
||||
|
||||
if(curarea->spacetype==SPACE_VIEW3D) {
|
||||
// panel now
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_NLA){
|
||||
//clever_numbuts_nla();
|
||||
// panel now
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_IPO) {
|
||||
// panel now
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_SEQ) {
|
||||
clever_numbuts_seq();
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_IMAGE) {
|
||||
// panel now
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_IMASEL) {
|
||||
clever_numbuts_imasel();
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_BUTS){
|
||||
clever_numbuts_buts();
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_OOPS) {
|
||||
clever_numbuts_oops();
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_ACTION){
|
||||
// in its own queue
|
||||
}
|
||||
else if(curarea->spacetype==SPACE_FILE) {
|
||||
clever_numbuts_filesel();
|
||||
|
|
Loading…
Reference in New Issue