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
path: root/source
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2004-04-26 18:17:48 +0400
committerTon Roosendaal <ton@blender.org>2004-04-26 18:17:48 +0400
commit0facc2681ef22eed76a52c195ca57049af32c5e5 (patch)
treee2f5ab3114ba6b1bf6cfaafaf46b7a9695277526 /source
parentd8ca2263c1d154891524f6426ca090e0fa6e9b62 (diff)
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.
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/world.c3
-rw-r--r--source/blender/blenloader/intern/readfile.c5
-rw-r--r--source/blender/makesdna/DNA_world_types.h2
-rw-r--r--source/blender/render/intern/source/ray.c15
-rw-r--r--source/blender/render/intern/source/renderdatabase.c12
-rw-r--r--source/blender/src/buttons_shading.c32
-rw-r--r--source/blender/src/toolbox.c7
7 files changed, 41 insertions, 35 deletions
diff --git a/source/blender/blenkernel/intern/world.c b/source/blender/blenkernel/intern/world.c
index 0780c7dbc48..d2cd0307c2c 100644
--- a/source/blender/blenkernel/intern/world.c
+++ b/source/blender/blenkernel/intern/world.c
@@ -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;
}
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6984f772c42..2a2ca1c7f2b 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -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;
diff --git a/source/blender/makesdna/DNA_world_types.h b/source/blender/makesdna/DNA_world_types.h
index baceb4e17e9..cda544df1d1 100644
--- a/source/blender/makesdna/DNA_world_types.h
+++ b/source/blender/makesdna/DNA_world_types.h
@@ -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;
diff --git a/source/blender/render/intern/source/ray.c b/source/blender/render/intern/source/ray.c
index 950b1334cf5..a664de41f05 100644
--- a/source/blender/render/intern/source/ray.c
+++ b/source/blender/render/intern/source/ray.c
@@ -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++;
diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c
index c9dddccdebd..b717029c4ba 100644
--- a/source/blender/render/intern/source/renderdatabase.c
+++ b/source/blender/render/intern/source/renderdatabase.c
@@ -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*));
diff --git a/source/blender/src/buttons_shading.c b/source/blender/src/buttons_shading.c
index 8efc58b0049..106ffeb3c15 100644
--- a/source/blender/src/buttons_shading.c
+++ b/source/blender/src/buttons_shading.c
@@ -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()
{
diff --git a/source/blender/src/toolbox.c b/source/blender/src/toolbox.c
index 42a2532e082..fa86a2da0a0 100644
--- a/source/blender/src/toolbox.c
+++ b/source/blender/src/toolbox.c
@@ -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();