Removed some testcode from yafray_Render.cpp

Added the missing anti-aliasing pixel filter size and threshold parameters for manual AA control (disable 'Auto AA' button).
Added support for yafray raytraced depth-of-field.
Added extra panel for Camera in edit window to edit dof paramaters.
The actual focus point will be drawn as a cross when camera 'ShowLimits' is enabled, similar to the aqsis code in tuhopuu.

Note to users: raytraced DoF is very slow, for best results, the default AA parameters are not good enough, especially with higher aperture values (more blur).
So for best results, disable 'Auto AA' and set the AA parameters yourself.
It works best with multi-pass AA ('AA passes' > 1) and a reasonable 'AA samples' value, something in the range 8 - 25 or even higher.
Currently the post-process DoF is not available in yafray, alternatives are being worked on.
This commit is contained in:
2004-07-13 19:22:41 +00:00
parent bf8c3e2020
commit b64afb526a
8 changed files with 95 additions and 37 deletions

View File

@@ -50,6 +50,9 @@ typedef struct Camera {
float clipsta, clipend;
float lens, drawsize;
/* yafray: dof params */
float YF_dofdist, YF_aperture;
struct Ipo *ipo;
ScriptLink scriptlink;
@@ -64,6 +67,8 @@ typedef struct Camera {
/* flag */
#define CAM_SHOWLIMITS 1
#define CAM_SHOWMIST 2
/* yafray: dof sampling switch */
#define CAM_YF_NO_QMC 4
#ifdef __cplusplus
}

View File

@@ -212,15 +212,15 @@ typedef struct RenderData {
/** post-production settings. Don't really belong here */
float postmul, postgamma, postadd, postigamma;
/* yafray: global panel params */
short GIquality, GIcache, GImethod, GIgradient,GIphotons,GIdirect;
/* yafray: global panel params. TODO: move elsewhere */
short GIquality, GIcache, GImethod, GIgradient, GIphotons, GIdirect;
short YF_AA, YFexportxml;
int GIdepth, GIcausdepth, GIpixelspersample;
int GIphotoncount,GImixphotons;
int GIphotoncount, GImixphotons;
float GIphotonradius;
int YF_numprocs,YF_raydepth, YF_AApasses, YF_AAsamples, YFintpad;
int YF_numprocs, YF_raydepth, YF_AApasses, YF_AAsamples;
float GIshadowquality, GIrefinement, GIpower;
float YF_gamma, YF_exposure,YF_raybias, YF_AAthreshold;
float YF_gamma, YF_exposure, YF_raybias, YF_AApixelsize, YF_AAthreshold;
char backbuf[160], pic[160], ftype[160];

View File

@@ -1309,6 +1309,23 @@ static void editing_panel_camera_type(Object *ob, Camera *cam)
uiBlockEndAlign(block);
}
/* yafray: extra camera panel to set Depth-of-Field parameters */
static void editing_panel_camera_yafraydof(Object *ob, Camera *cam)
{
uiBlock *block;
block= uiNewBlock(&curarea->uiblocks, "editing_panel_camera_yafraydof", UI_EMBOSS, UI_HELV, curarea->win);
uiNewPanelTabbed("Camera", "Editing");
if(uiNewPanel(curarea, block, "Yafray DoF", "Editing", 320, 0, 318, 204)==0) return;
uiDefButF(block, NUM, REDRAWVIEW3D, "DoFDist:", 470, 147, 160, 20, &cam->YF_dofdist, 0.0, 5000.0, 100, 0, "Sets distance to point of focus (use camera 'ShowLimits' to make visible in 3Dview)");
uiDefButF(block, NUM, REDRAWVIEW3D, "Aperture:", 470, 125, 160, 20, &cam->YF_aperture, 0.0, 2.0, 0, 0, "Sets lens aperture, the larger, the more blur (use small values, 0 is no DoF)");
uiDefButS(block, TOG|BIT|2, 0, "Random sampling", 470, 90, 160, 20, &cam->flag, 0, 0, 0, 0, "Use noisy random Lens sampling instead of QMC");
}
/* *************************** MBALL ******************************** */
void do_mballbuts(unsigned short event)
@@ -2587,6 +2604,8 @@ void editing_panels()
cam= ob->data;
editing_panel_links(ob); // no editmode!
editing_panel_camera_type(ob, cam);
/* yafray: extra panel for dof parameters */
if (G.scene->r.renderer==R_YAFRAY) editing_panel_camera_yafraydof(ob, cam);
break;
case OB_ARMATURE:

View File

@@ -1303,15 +1303,15 @@ static void render_panel_yafrayGlobal()
/*AA Settings*/
uiDefButS(block,TOGN|BIT|0, B_REDR, "Auto AA",5,110,150,20, &G.scene->r.YF_AA,
uiDefButS(block,TOGN|BIT|0, B_REDR, "Auto AA", 5,140,150,20, &G.scene->r.YF_AA,
0, 0, 0, 0, "Set AA using OSA and GI quality, disable for manual control");
uiDefButS(block,TOGN|BIT|0, B_REDR, "xml",175,110,75,20, &G.scene->r.YFexportxml,
uiDefButS(block,TOGN|BIT|0, B_REDR, "xml", 175,140,75,20, &G.scene->r.YFexportxml,
0, 0, 0, 0, "Export to an xml file and call yafray instead of plugin");
if(G.scene->r.YF_AA){
uiDefButI(block, NUM, 0, "AA Passes ", 5,85,150,20,
&G.scene->r.YF_AApasses, 0, 64, 10, 10, "AA Passes");
uiDefButI(block, NUM, 0, "AA Samples ", 160,85,150,20,
&G.scene->r.YF_AAsamples, 0, 2048, 10, 10, "AA Samples");
uiDefButI(block, NUM, 0, "AA Passes ", 5,115,150,20, &G.scene->r.YF_AApasses, 0, 64, 10, 10, "Number of AA passes (0 is no AA)");
uiDefButI(block, NUM, 0, "AA Samples ", 160,115,150,20, &G.scene->r.YF_AAsamples, 0, 2048, 10, 10, "Number of samples per pass");
uiDefButF(block, NUMSLI, 0, "Psz ", 5,90,150,20, &G.scene->r.YF_AApixelsize, 1.0, 2.0, 0, 0, "AA pixel filter size");
uiDefButF(block, NUMSLI, 0, "Thr ", 160,90,150,20, &G.scene->r.YF_AAthreshold, 0.000001, 1.0, 0, 0, "AA threshold");
}
}
@@ -1328,6 +1328,8 @@ void render_panels()
if (G.scene->r.YF_gamma==0.0) G.scene->r.YF_gamma=1.0;
if (G.scene->r.YF_raybias==0.0) G.scene->r.YF_raybias=0.001;
if (G.scene->r.YF_raydepth==0) G.scene->r.YF_raydepth=5;
if (G.scene->r.YF_AApixelsize==0.0) G.scene->r.YF_AApixelsize=1.5;
if (G.scene->r.YF_AAthreshold==0.0) G.scene->r.YF_AAthreshold=0.05;
render_panel_yafrayGlobal();
render_panel_yafrayGI();
}

View File

@@ -644,6 +644,17 @@ static void draw_limit_line(float sta, float end, unsigned int col)
}
/* yafray: draw camera focus point (cross, similar to aqsis code in tuhopuu) */
static void draw_focus_cross(float dist, float size)
{
glBegin(GL_LINES);
glVertex3f(-size, 0.f, -dist);
glVertex3f(size, 0.f, -dist);
glVertex3f(0.f, -size, -dist);
glVertex3f(0.f, size, -dist);
glEnd();
}
void drawcamera(Object *ob)
{
/* a standing up pyramid with (0,0,0) as top */
@@ -735,8 +746,11 @@ void drawcamera(Object *ob)
MTC_Mat4SwapMat4(G.vd->persmat, tmat);
mygetsingmatrix(G.vd->persmat);
if(cam->flag & CAM_SHOWLIMITS)
if(cam->flag & CAM_SHOWLIMITS) {
draw_limit_line(cam->clipsta, cam->clipend, 0x77FFFF);
/* yafray: dof focus point */
if (G.scene->r.renderer==R_YAFRAY) draw_focus_cross(cam->YF_dofdist, cam->drawsize);
}
wrld= G.scene->world;
if(cam->flag & CAM_SHOWMIST)

View File

@@ -204,24 +204,24 @@ bool yafrayFileRender_t::writeRender()
ostr << "<render camera_name=\"MAINCAM\"\n";
ostr << "\traydepth=\"" << R.r.YF_raydepth << "\" gamma=\"" << R.r.YF_gamma << "\" exposure=\"" << R.r.YF_exposure << "\"\n";
if(R.r.YF_AA)
ostr << "\tAA_passes=\"" << R.r.YF_AApasses << "\" AA_minsamples=\"" << R.r.YF_AAsamples << "\"";
if(R.r.YF_AA) {
ostr << "\tAA_passes=\"" << R.r.YF_AApasses << "\" AA_minsamples=\"" << R.r.YF_AAsamples << "\"\n";
ostr << "\tAA_pixelwidth=\"" << R.r.YF_AApixelsize << "\" AA_threshold=\"" << R.r.YF_AAthreshold << "\"\n";
}
else {
if ((R.r.GImethod!=0) && (R.r.GIquality>1) && (!R.r.GIcache))
ostr << "\tAA_passes=\"5\" AA_minsamples=\"5\" " << endl;
ostr << "\tAA_passes=\"5\" AA_minsamples=\"5\"\n";
else if ((R.r.mode & R_OSA) && (R.r.osa)) {
int passes=(R.r.osa%4)==0 ? R.r.osa/4 : 1;
int minsamples=(R.r.osa%4)==0 ? 4 : R.r.osa;
ostr << "\tAA_passes=\"" << passes << "\" AA_minsamples=\"" << minsamples << "\"";
ostr << "\tAA_passes=\"" << passes << "\" AA_minsamples=\"" << minsamples << "\"\n";
}
else ostr << "\tAA_passes=\"0\" AA_minsamples=\"1\"";
else ostr << "\tAA_passes=\"0\" AA_minsamples=\"1\"\n";
ostr << "\tAA_pixelwidth=\"1.5\" AA_threshold=\"0.05\" bias=\"" << R.r.YF_raybias << "\"\n";
}
ostr << "\n";
if (hasworld) ostr << "\tbackground_name=\"world_background\"\n";
ostr << "\tAA_pixelwidth=\"2\" AA_threshold=\"0.05\" bias=\"" << R.r.YF_raybias << "\"";
// alpha channel render when RGBA button enabled
if (R.r.planes==R_PLANES32) ostr << "\n\tsave_alpha=\"on\"";
ostr << " >\n";
@@ -1121,7 +1121,7 @@ void yafrayFileRender_t::writeLamps()
string lpmode="off";
// shadows only when Blender has shadow button enabled, only spots use LA_SHAD flag
if (R.r.mode & R_SHADOW)
if (((lamp->type==LA_SPOT) && (lamp->mode & LA_SHAD)) || (lamp->mode & LA_SHAD_RAY)) lpmode="on";;
if (((lamp->type==LA_SPOT) && (lamp->mode & LA_SHAD)) || (lamp->mode & LA_SHAD_RAY)) lpmode="on";
ostr << "\" cast_shadows=\"" << lpmode << "\"";
// spot specific stuff
if (lamp->type==LA_SPOT) {
@@ -1182,7 +1182,19 @@ void yafrayFileRender_t::writeCamera()
float aspect = 1;
if (R.r.xsch < R.r.ysch) aspect = float(R.r.xsch)/float(R.r.ysch);
ostr << "\" focal=\"" << mainCamLens/(aspect*32.0) << "\" >\n";
ostr << "\" focal=\"" << mainCamLens/(aspect*32.0) << "\"";
// dof params, only valid for real camera
if (maincam_obj->type==OB_CAMERA) {
Camera* cam = (Camera*)maincam_obj->data;
ostr << "\n\tdof_distance=\"" << cam->YF_dofdist << "\"";
ostr << " aperture=\"" << cam->YF_aperture << "\"";
string st = "on";
if (cam->flag & CAM_YF_NO_QMC) st = "off";
ostr << " use_qmc=\"" << st << "\"";
}
ostr << " >\n";
xmlfile << ostr.str();
ostr.str("");
@@ -1197,7 +1209,6 @@ void yafrayFileRender_t::writeCamera()
ostr << "\t<up x=\"" << maincam_obj->obmat[3][0] + R.viewmat[0][1]
<< "\" y=\"" << maincam_obj->obmat[3][1] + R.viewmat[1][1]
<< "\" z=\"" << maincam_obj->obmat[3][2] + R.viewmat[2][1] << "\" />\n";
// add dof_distance param here
xmlfile << ostr.str();
xmlfile << "</camera>\n\n";

View File

@@ -210,10 +210,12 @@ bool yafrayPluginRender_t::writeRender()
params["raydepth"]=yafray::parameter_t((float)R.r.YF_raydepth);
params["gamma"]=yafray::parameter_t(R.r.YF_gamma);
params["exposure"]=yafray::parameter_t(R.r.YF_exposure);
if(R.r.YF_AA)
if (R.r.YF_AA)
{
params["AA_passes"]=yafray::parameter_t((int)R.r.YF_AApasses);
params["AA_minsamples"]=yafray::parameter_t(R.r.YF_AAsamples);
params["AA_passes"] = yafray::parameter_t((int)R.r.YF_AApasses);
params["AA_minsamples"] = yafray::parameter_t(R.r.YF_AAsamples);
params["AA_pixelwidth"] = yafray::parameter_t(R.r.YF_AApixelsize);
params["AA_threshold"] = yafray::parameter_t(R.r.YF_AAthreshold);
}
else
{
@@ -232,10 +234,10 @@ bool yafrayPluginRender_t::writeRender()
params["AA_passes"]=yafray::parameter_t(0);
params["AA_minsamples"]=yafray::parameter_t(1);
}
}
if (hasworld) params["background_name"]=yafray::parameter_t("world_background");
params["AA_pixelwidth"]=yafray::parameter_t(1.5);
params["AA_threshold"]=yafray::parameter_t(0.05f);
}
if (hasworld) params["background_name"]=yafray::parameter_t("world_background");
params["bias"]=yafray::parameter_t(R.r.YF_raybias);
//params["outfile"]=yafray::parameter_t(imgout);
blenderYafrayOutput_t output;
@@ -1190,6 +1192,18 @@ void yafrayPluginRender_t::writeCamera()
if (R.r.xsch < R.r.ysch) aspect = float(R.r.xsch)/float(R.r.ysch);
params["focal"]=yafray::parameter_t(mainCamLens/(aspect*32.0));
// dof params, only valid for real camera
if (maincam_obj->type==OB_CAMERA) {
Camera* cam = (Camera*)maincam_obj->data;
params["dof_distance"] = yafray::parameter_t(cam->YF_dofdist);
params["aperture"] = yafray::parameter_t(cam->YF_aperture);
if (cam->flag & CAM_YF_NO_QMC)
params["use_qmc"] = yafray::parameter_t("off");
else
params["use_qmc"] = yafray::parameter_t("on");
}
params["from"]=yafray::parameter_t(
yafray::point3d_t(maincam_obj->obmat[3][0], maincam_obj->obmat[3][1], maincam_obj->obmat[3][2]));
float fdist = -R.viewmat[3][2];
@@ -1202,7 +1216,7 @@ void yafrayPluginRender_t::writeCamera()
yafray::point3d_t(maincam_obj->obmat[3][0] + R.viewmat[0][1],
maincam_obj->obmat[3][1] + R.viewmat[1][1],
maincam_obj->obmat[3][2] + R.viewmat[2][1]));
// add dof_distance param here
yafrayGate->addCamera(params);
}

View File

@@ -137,13 +137,6 @@ bool yafrayRender_t::getAllMatTexObs()
}
// test
for (map<string, vector<float> >::const_iterator obn=dupliMtx_list.begin();
obn!=dupliMtx_list.end();++obn)
{
cout << obn->first << endl;
}
// in case dupliMtx_list not empty, make sure that there is at least one source object
// in all_objects with the name given in dupliMtx_list
if (!dupliMtx_list.empty()) {