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
diff options
context:
space:
mode:
authorAlfredo de Greef <eeshlo@yahoo.com>2004-11-08 06:55:44 +0300
committerAlfredo de Greef <eeshlo@yahoo.com>2004-11-08 06:55:44 +0300
commit459deaf11f3f451b2f30b97b1e23e72343398445 (patch)
treee88c2e842c843cd8c5bee06a398e6feac0521c85
parent8daff51e0fab7bf06847e4e019d7b0b21ab4bb69 (diff)
Fixed:
Texture matrix bug in plugin code reported by Mel_Q. Vertex colors, this was basically the same as the previous uv coord splitting bug, for xml export, uv coord splitting was actually not quite complete either (reported by richie). Added: Camera Ipo curves for DoF aperture and focal distance. Aspect ratio set with AspX & AspY are now taken into account as well. (needs yafray from cvs) Bokeh parameters for DoF (also needs yafray from cvs). 'Bokeh' controls the shape of out of focus points when rendering with depth of field enabled. This is mostly visible on very out of focus highlights in the image. There are currently seven types to choose from.: 'Disk1' is the default, the same as was used before. 'Disk2' is similar, but allows you to modify the shape further with the 'bias' parameter, see below. Triangle/Square/Pentagon/Hexagon, in addition to the bias control, you can offset the rotation with the 'Rotation' parameter (in degrees). 'Ring', a weird ring shaped lens, no additional controls. The 'bias' menu controls accentuation of the shape. Three types available, uniform, center or edge, with uniform the default. Although based on an actual phenomenon of real camera's, the current code is bit of a hack and not physically based, and doesn't work all that well yet (in yafray anyway). Since this is also mostly visible in the very out of focus parts of the image, it usually also means that you need lots of samples to get a reasonably smooth result.
-rw-r--r--source/blender/blenkernel/intern/ipo.c20
-rw-r--r--source/blender/makesdna/DNA_camera_types.h2
-rw-r--r--source/blender/makesdna/DNA_ipo_types.h9
-rw-r--r--source/blender/src/buttons_editing.c18
-rw-r--r--source/blender/src/editipo.c21
-rwxr-xr-xsource/blender/yafray/intern/export_File.cpp102
-rw-r--r--source/blender/yafray/intern/export_Plugin.cpp77
-rw-r--r--source/blender/yafray/intern/export_Plugin.h3
-rw-r--r--source/blender/yafray/intern/yafray_Render.cpp12
-rw-r--r--source/blender/yafray/intern/yafray_Render.h3
10 files changed, 175 insertions, 92 deletions
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index d7d373bbd3f..9476cd1aab7 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -168,8 +168,9 @@ int la_ar[LA_TOTIPO]= {
MA_MAP1+MAP_DVAR, MA_MAP1+MAP_COLF, MA_MAP1+MAP_NORF, MA_MAP1+MAP_VARF
};
+/* yafray: aperture & focal distance curves added */
int cam_ar[CAM_TOTIPO]= {
- CAM_LENS, CAM_STA, CAM_END
+ CAM_LENS, CAM_STA, CAM_END, CAM_YF_APERT, CAM_YF_FDIST
};
int snd_ar[SND_TOTIPO]= {
@@ -1305,6 +1306,7 @@ void *get_ipo_poin(ID *id, IpoCurve *icu, int *type)
else if(GS(id->name)==ID_CA) {
Camera *ca= (Camera *)id;
+ /* yafray: aperture & focal distance params */
switch(icu->adrcode) {
case CAM_LENS:
poin= &(ca->lens); break;
@@ -1312,6 +1314,10 @@ void *get_ipo_poin(ID *id, IpoCurve *icu, int *type)
poin= &(ca->clipsta); break;
case CAM_END:
poin= &(ca->clipend); break;
+ case CAM_YF_APERT:
+ poin= &(ca->YF_aperture); break;
+ case CAM_YF_FDIST:
+ poin= &(ca->YF_dofdist); break;
}
}
else if(GS(id->name)==ID_SO) {
@@ -1563,15 +1569,25 @@ void set_icu_vars(IpoCurve *icu)
}
else if(icu->blocktype==ID_CA) {
+ /* yafray: aperture & focal distance params */
switch(icu->adrcode) {
case CAM_LENS:
icu->ymin= 5.0;
- icu->ymax= 1000.0; break;
+ icu->ymax= 1000.0;
+ break;
case CAM_STA:
icu->ymin= 0.001f;
break;
case CAM_END:
icu->ymin= 0.1f;
+ break;
+ case CAM_YF_APERT:
+ icu->ymin = 0.0;
+ icu->ymax = 2.0;
+ break;
+ case CAM_YF_FDIST:
+ icu->ymin = 0.0;
+ icu->ymax = 5000.0;
}
}
else if(icu->blocktype==ID_SO) {
diff --git a/source/blender/makesdna/DNA_camera_types.h b/source/blender/makesdna/DNA_camera_types.h
index 2df957561dc..1f25f371f97 100644
--- a/source/blender/makesdna/DNA_camera_types.h
+++ b/source/blender/makesdna/DNA_camera_types.h
@@ -52,6 +52,8 @@ typedef struct Camera {
/* yafray: dof params */
float YF_dofdist, YF_aperture;
+ short YF_bkhtype, YF_bkhbias;
+ float YF_bkhrot;
struct Ipo *ipo;
diff --git a/source/blender/makesdna/DNA_ipo_types.h b/source/blender/makesdna/DNA_ipo_types.h
index a81c21ad19f..8363fa0481a 100644
--- a/source/blender/makesdna/DNA_ipo_types.h
+++ b/source/blender/makesdna/DNA_ipo_types.h
@@ -268,13 +268,16 @@ typedef short IPO_Channel;
/* ******************** */
-#define CAM_TOTIPO 3
-#define CAM_TOTNAM 3
+/* yafray: totipo & totnam +2 because of added curves */
+#define CAM_TOTIPO 5
+#define CAM_TOTNAM 5
#define CAM_LENS 1
#define CAM_STA 2
#define CAM_END 3
-
+/* yafray aperture & focal distance curves */
+#define CAM_YF_APERT 4
+#define CAM_YF_FDIST 5
/* ******************** */
diff --git a/source/blender/src/buttons_editing.c b/source/blender/src/buttons_editing.c
index 2fd8a190196..b422ffbdc82 100644
--- a/source/blender/src/buttons_editing.c
+++ b/source/blender/src/buttons_editing.c
@@ -1331,15 +1331,27 @@ static void editing_panel_camera_type(Object *ob, Camera *cam)
static void editing_panel_camera_yafraydof(Object *ob, Camera *cam)
{
uiBlock *block;
+ char *mst1, *mst2;
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)");
+ uiDefButF(block, NUM, REDRAWVIEW3D, "DoFDist:", 10, 147, 180, 20, &cam->YF_dofdist, 0.0, 5000.0, 50, 0, "Sets distance to point of focus (use camera 'ShowLimits' to make visible in 3Dview)");
+ uiDefButF(block, NUM, B_DIFF, "Aperture:", 10, 125, 180, 20, &cam->YF_aperture, 0.0, 2.0, 1, 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");
+ uiDefButS(block, TOG|BIT|2, B_DIFF, "Random sampling", 10, 90, 180, 20, &cam->flag, 0, 0, 0, 0, "Use noisy random Lens sampling instead of QMC");
+
+ uiDefBut(block, LABEL, 0, "Bokeh", 10, 60, 180, 19, 0, 0.0, 0.0, 0, 0, "");
+ mst1 = "Bokeh Type%t|Disk1%x0|Disk2%x1|Triangle%x2|Square%x3|Pentagon%x4|Hexagon%x5|Ring%x6";
+ uiDefButS(block, MENU, B_REDR, mst1, 10, 40, 89, 20, &cam->YF_bkhtype, 0.0, 0.0, 0, 0, "Sets Bokeh type");
+
+ if ((cam->YF_bkhtype!=0) && (cam->YF_bkhtype!=6)) {
+ mst2 = "Bokeh Bias%t|Uniform%x0|Center%x1|Edge%x2";
+ uiDefButS(block, MENU, B_REDR, mst2, 100, 40, 90, 20, &cam->YF_bkhbias, 0.0, 0.0, 0, 0, "Sets Bokeh bias");
+ if (cam->YF_bkhtype>1)
+ uiDefButF(block, NUM, B_DIFF, "Rotation:", 10, 15, 180, 20, &cam->YF_bkhrot, 0.0, 360.0, 100, 0, "Shape rotation amount in degrees");
+ }
}
diff --git a/source/blender/src/editipo.c b/source/blender/src/editipo.c
index 02505a7986d..9d7d02f80db 100644
--- a/source/blender/src/editipo.c
+++ b/source/blender/src/editipo.c
@@ -180,7 +180,8 @@ char *wo_ic_names[WO_TOTNAM] = { "HorR", "HorG", "HorB", "ZenR", "ZenG", "ZenB",
"StarG", "StarDi", "StarSi" };
char *la_ic_names[LA_TOTNAM] = { "Energ", "R", "G", "B", "Dist", "SpoSi", "SpoBl",
"Quad1", "Quad2", "HaInt" };
-char *cam_ic_names[CAM_TOTNAM] = { "Lens", "ClSta", "ClEnd" };
+/* yafray: two curve names added, 'Apert' for aperture, and 'FDist' for focal distance */
+char *cam_ic_names[CAM_TOTNAM] = { "Lens", "ClSta", "ClEnd", "Apert", "FDist" };
char *snd_ic_names[SND_TOTNAM] = { "Vol", "Pitch", "Pan", "Atten" };
char *ac_ic_names[AC_TOTNAM] = {"LocX", "LocY", "LocZ", "SizeX", "SizeY",
"SizeZ", "QuatW", "QuatX", "QuatY", "QuatZ"};
@@ -286,7 +287,9 @@ char *getname_la_ei(int nr)
char *getname_cam_ei(int nr)
{
- if(nr>=CAM_LENS && nr<=CAM_END) return cam_ic_names[nr-1];
+ /* yafray: curves extended to CAM_YF_FDIST */
+ //if(nr>=CAM_LENS && nr<=CAM_END) return cam_ic_names[nr-1];
+ if(nr>=CAM_LENS && nr<=CAM_YF_FDIST) return cam_ic_names[nr-1];
return ic_name_empty[0];
}
@@ -3781,16 +3784,26 @@ void common_insertkey()
if(ob && ob->type==OB_CAMERA) {
id= G.buts->lockpoin;
if(id) {
- event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1");
+ /* yafray: insert key extended with aperture and focal distance */
+ if (G.scene->r.renderer==R_INTERN)
+ event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1");
+ else
+ event= pupmenu("Insert Key %t|Lens%x0|Clipping%x1|Aperture%x2|FocalDistance%x3");
if(event== -1) return;
if(event==0) {
insertkey(id, CAM_LENS);
}
- if(event==1) {
+ else if(event==1) {
insertkey(id, CAM_STA);
insertkey(id, CAM_END);
}
+ else if(event==2) {
+ insertkey(id, CAM_YF_APERT);
+ }
+ else if(event==3) {
+ insertkey(id, CAM_YF_FDIST);
+ }
}
}
}
diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp
index eca34a65504..4bae9520a90 100755
--- a/source/blender/yafray/intern/export_File.cpp
+++ b/source/blender/yafray/intern/export_File.cpp
@@ -1107,15 +1107,16 @@ void yafrayFileRender_t::writeObject(Object* obj, const vector<VlakRen*> &VLR_li
ostr.str("");
ostr << "\t\t\t<f a=\"" << idx1 << "\" b=\"" << idx2 << "\" c=\"" << idx3 << "\"";
+ // triangle uv and vcol indices
+ int ui1=0, ui2=1, ui3=2;
+ if (vlr->flag & R_DIVIDE_24) {
+ ui3++;
+ if (vlr->flag & R_FACE_SPLIT) { ui1++; ui2++; }
+ }
+ else if (vlr->flag & R_FACE_SPLIT) { ui2++; ui3++; }
+
TFace* uvc = vlr->tface; // possible uvcoords (v upside down)
if (uvc) {
- // use correct uv coords for this triangle
- int ui1=0, ui2=1, ui3=2;
- if (vlr->flag & R_DIVIDE_24) {
- ui3++;
- if (vlr->flag & R_FACE_SPLIT) { ui1++; ui2++; }
- }
- else if (vlr->flag & R_FACE_SPLIT) { ui2++; ui3++; }
ostr << " u_a=\"" << uvc->uv[ui1][0] << "\" v_a=\"" << 1-uvc->uv[ui1][1] << "\""
<< " u_b=\"" << uvc->uv[ui2][0] << "\" v_b=\"" << 1-uvc->uv[ui2][1] << "\""
<< " u_c=\"" << uvc->uv[ui3][0] << "\" v_c=\"" << 1-uvc->uv[ui3][1] << "\"";
@@ -1125,17 +1126,17 @@ void yafrayFileRender_t::writeObject(Object* obj, const vector<VlakRen*> &VLR_li
if ((EXPORT_VCOL) && (vlr->vcol)) {
// vertex colors
float vr, vg, vb;
- vr = ((vlr->vcol[0] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[0] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[0] >> 8) & 255)/255.0;
+ vr = ((vlr->vcol[ui1] >> 24) & 255)/255.0;
+ vg = ((vlr->vcol[ui1] >> 16) & 255)/255.0;
+ vb = ((vlr->vcol[ui1] >> 8) & 255)/255.0;
ostr << " vcol_a_r=\"" << vr << "\" vcol_a_g=\"" << vg << "\" vcol_a_b=\"" << vb << "\"";
- vr = ((vlr->vcol[1] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[1] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[1] >> 8) & 255)/255.0;
+ vr = ((vlr->vcol[ui2] >> 24) & 255)/255.0;
+ vg = ((vlr->vcol[ui2] >> 16) & 255)/255.0;
+ vb = ((vlr->vcol[ui2] >> 8) & 255)/255.0;
ostr << " vcol_b_r=\"" << vr << "\" vcol_b_g=\"" << vg << "\" vcol_b_b=\"" << vb << "\"";
- vr = ((vlr->vcol[2] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[2] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[2] >> 8) & 255)/255.0;
+ vr = ((vlr->vcol[ui3] >> 24) & 255)/255.0;
+ vg = ((vlr->vcol[ui3] >> 16) & 255)/255.0;
+ vb = ((vlr->vcol[ui3] >> 8) & 255)/255.0;
ostr << " vcol_c_r=\"" << vr << "\" vcol_c_g=\"" << vg << "\" vcol_c_b=\"" << vb << "\"";
}
ostr << " shader_name=\"" << fmatname << "\" />\n";
@@ -1151,25 +1152,30 @@ void yafrayFileRender_t::writeObject(Object* obj, const vector<VlakRen*> &VLR_li
ostr << "\t\t\t<f a=\"" << idx1 << "\" b=\"" << idx2 << "\" c=\"" << idx3 << "\"";
+ // increment uv & vcol indices
+ ui1 = (ui1+2) & 3;
+ ui2 = (ui2+2) & 3;
+ ui3 = (ui3+2) & 3;
+
if (uvc) {
- ostr << " u_a=\"" << uvc->uv[2][0] << "\" v_a=\"" << 1-uvc->uv[2][1] << "\""
- << " u_b=\"" << uvc->uv[3][0] << "\" v_b=\"" << 1-uvc->uv[3][1] << "\""
- << " u_c=\"" << uvc->uv[0][0] << "\" v_c=\"" << 1-uvc->uv[0][1] << "\"";
+ ostr << " u_a=\"" << uvc->uv[ui1][0] << "\" v_a=\"" << 1-uvc->uv[ui1][1] << "\""
+ << " u_b=\"" << uvc->uv[ui2][0] << "\" v_b=\"" << 1-uvc->uv[ui2][1] << "\""
+ << " u_c=\"" << uvc->uv[ui3][0] << "\" v_c=\"" << 1-uvc->uv[ui3][1] << "\"";
}
if ((EXPORT_VCOL) && (vlr->vcol)) {
// vertex colors
float vr, vg, vb;
- vr = ((vlr->vcol[2] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[2] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[2] >> 8) & 255)/255.0;
+ vr = ((vlr->vcol[ui1] >> 24) & 255)/255.0;
+ vg = ((vlr->vcol[ui1] >> 16) & 255)/255.0;
+ vb = ((vlr->vcol[ui1] >> 8) & 255)/255.0;
ostr << " vcol_a_r=\"" << vr << "\" vcol_a_g=\"" << vg << "\" vcol_a_b=\"" << vb << "\"";
- vr = ((vlr->vcol[3] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[3] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[3] >> 8) & 255)/255.0;
+ vr = ((vlr->vcol[ui2] >> 24) & 255)/255.0;
+ vg = ((vlr->vcol[ui2] >> 16) & 255)/255.0;
+ vb = ((vlr->vcol[ui2] >> 8) & 255)/255.0;
ostr << " vcol_b_r=\"" << vr << "\" vcol_b_g=\"" << vg << "\" vcol_b_b=\"" << vb << "\"";
- vr = ((vlr->vcol[0] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[0] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[0] >> 8) & 255)/255.0;
+ vr = ((vlr->vcol[ui3] >> 24) & 255)/255.0;
+ vg = ((vlr->vcol[ui3] >> 16) & 255)/255.0;
+ vb = ((vlr->vcol[ui3] >> 8) & 255)/255.0;
ostr << " vcol_c_r=\"" << vr << "\" vcol_c_g=\"" << vg << "\" vcol_c_b=\"" << vb << "\"";
}
ostr << " shader_name=\"" << fmatname << "\" />\n";
@@ -1443,7 +1449,6 @@ void yafrayFileRender_t::writeLamps()
}
}
-
// write main camera
void yafrayFileRender_t::writeCamera()
{
@@ -1456,15 +1461,12 @@ void yafrayFileRender_t::writeCamera()
ostr << "type=\"perspective\"";
// render resolution including the percentage buttons (aleady calculated in initrender for R renderdata)
- int xres = R.r.xsch;
- int yres = R.r.ysch;
- ostr << " resx=\"" << xres << "\" resy=\"" << yres;
-
- // aspectratio can be set in Blender as well using aspX & aspY, need an extra param. for yafray cam.
- float aspect = 1;
- if (R.r.xsch < R.r.ysch) aspect = float(R.r.xsch)/float(R.r.ysch);
+ ostr << " resx=\"" << R.r.xsch << "\" resy=\"" << R.r.ysch << "\"";
- ostr << "\" focal=\"" << mainCamLens/(aspect*32.0) << "\"";
+ float f_aspect = 1;
+ if ((R.r.xsch*R.r.xasp)<=(R.r.ysch*R.r.yasp)) f_aspect = float(R.r.xsch*R.r.xasp)/float(R.r.ysch*R.r.yasp);
+ ostr << "\n\tfocal=\"" << mainCamLens/(f_aspect*32.f);
+ ostr << "\" aspect_ratio=\"" << R.ycor << "\"";
// dof params, only valid for real camera
if (maincam_obj->type==OB_CAMERA) {
@@ -1474,6 +1476,28 @@ void yafrayFileRender_t::writeCamera()
string st = "on";
if (cam->flag & CAM_YF_NO_QMC) st = "off";
ostr << " use_qmc=\"" << st << "\"";
+ // bokeh params
+ st = "disk1";
+ if (cam->YF_bkhtype==1)
+ st = "disk2";
+ else if (cam->YF_bkhtype==2)
+ st = "triangle";
+ else if (cam->YF_bkhtype==3)
+ st = "square";
+ else if (cam->YF_bkhtype==4)
+ st = "pentagon";
+ else if (cam->YF_bkhtype==5)
+ st = "hexagon";
+ else if (cam->YF_bkhtype==6)
+ st = "ring";
+ ostr << "\n\tbokeh_type=\"" << st << "\"";
+ st = "uniform";
+ if (cam->YF_bkhbias==1)
+ st = "center";
+ else if (cam->YF_bkhbias==2)
+ st = "edge";
+ ostr << " bokeh_bias=\"" << st << "\"";
+ ostr << " bokeh_rotation=\"" << cam->YF_bkhrot << "\"";
}
ostr << " >\n";
@@ -1537,10 +1561,8 @@ void yafrayFileRender_t::writePathlight()
case 5 : ostr << " samples=\"2048\" \n"; break;
default: ostr << " samples=\"512\" \n";
}
- float aspect = 1;
- if (R.r.xsch < R.r.ysch) aspect = float(R.r.xsch)/float(R.r.ysch);
float sbase = 2.0/float(R.r.xsch);
- ostr << " cache=\"on\" use_QMC=\"on\" threshold=\"" <<R.r.GIrefinement<<"\""<<endl;
+ ostr << " cache=\"on\" use_QMC=\"on\" threshold=\"" << R.r.GIrefinement << "\"" << endl;
ostr << " cache_size=\"" << sbase*R.r.GIpixelspersample << "\" shadow_threshold=\"" <<
1.0 - R.r.GIshadowquality << "\" grid=\"82\" search=\"35\" >\n";
}
diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp
index 94afe696a3b..0db51bb0120 100644
--- a/source/blender/yafray/intern/export_Plugin.cpp
+++ b/source/blender/yafray/intern/export_Plugin.cpp
@@ -756,6 +756,8 @@ void yafrayPluginRender_t::writeMaterialsAndModulators()
map<string, MTex*>::const_iterator mtexL = used_textures.find(string(tex->id.name));
if (mtexL!=used_textures.end())
{
+ params.clear(); //!!!
+ lparams.clear();
char temp[32];
sprintf(temp, "_map%d", m);
params["type"] = yafray::parameter_t("blendermapper");
@@ -909,7 +911,7 @@ void yafrayPluginRender_t::genUVcoords(vector<yafray::GFLOAT> &uvcoords, VlakRen
{
if (uvc)
{
- // use correct uv coords for this triangle
+ // tri uv split indices
int ui1=0, ui2=1, ui3=2;
if (vlr->flag & R_DIVIDE_24) {
ui3++;
@@ -933,24 +935,33 @@ void yafrayPluginRender_t::genUVcoords(vector<yafray::GFLOAT> &uvcoords, VlakRen
}
}
-void yafrayPluginRender_t::genVcol(vector<yafray::CFLOAT> &vcol,VlakRen *vlr,
- int p1,int p2,int p3)
+void yafrayPluginRender_t::genVcol(vector<yafray::CFLOAT> &vcol, VlakRen *vlr, bool comple)
{
if (vlr->vcol)
{
- // vertex colors
- float vr, vg, vb;
- vr = ((vlr->vcol[p1] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[p1] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[p1] >> 8) & 255)/255.0;
+ // tri vcol split indices
+ int ui1=0, ui2=1, ui3=2;
+ if (vlr->flag & R_DIVIDE_24) {
+ ui3++;
+ if (vlr->flag & R_FACE_SPLIT) { ui1++; ui2++; }
+ }
+ else if (vlr->flag & R_FACE_SPLIT) { ui2++; ui3++; }
+ if (comple) {
+ ui1 = (ui1+2) & 3;
+ ui2 = (ui2+2) & 3;
+ ui3 = (ui3+2) & 3;
+ }
+ float vr = ((vlr->vcol[ui1] >> 24) & 255)/255.0;
+ float vg = ((vlr->vcol[ui1] >> 16) & 255)/255.0;
+ float vb = ((vlr->vcol[ui1] >> 8) & 255)/255.0;
vcol.push_back(vr); vcol.push_back(vg); vcol.push_back(vb);
- vr = ((vlr->vcol[p2] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[p2] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[p2] >> 8) & 255)/255.0;
+ vr = ((vlr->vcol[ui2] >> 24) & 255)/255.0;
+ vg = ((vlr->vcol[ui2] >> 16) & 255)/255.0;
+ vb = ((vlr->vcol[ui2] >> 8) & 255)/255.0;
vcol.push_back(vr); vcol.push_back(vg); vcol.push_back(vb);
- vr = ((vlr->vcol[p3] >> 24) & 255)/255.0;
- vg = ((vlr->vcol[p3] >> 16) & 255)/255.0;
- vb = ((vlr->vcol[p3] >> 8) & 255)/255.0;
+ vr = ((vlr->vcol[ui3] >> 24) & 255)/255.0;
+ vg = ((vlr->vcol[ui3] >> 16) & 255)/255.0;
+ vb = ((vlr->vcol[ui3] >> 8) & 255)/255.0;
vcol.push_back(vr); vcol.push_back(vg); vcol.push_back(vb);
}
else
@@ -1003,10 +1014,8 @@ void yafrayPluginRender_t::genFace(vector<int> &faces,vector<string> &shaders,ve
faces.push_back(idx1); faces.push_back(idx2); faces.push_back(idx3);
- if(has_uv) genUVcoords(uvcoords,vlr,uvc);
-
- // since Blender seems to need vcols when uvs are used, for yafray only export when the material actually uses vcols
- if (EXPORT_VCOL) genVcol(vcol, vlr, 0, 1, 2);
+ if(has_uv) genUVcoords(uvcoords, vlr, uvc);
+ if (EXPORT_VCOL) genVcol(vcol, vlr);
}
void yafrayPluginRender_t::genCompleFace(vector<int> &faces,/*vector<string> &shaders,*/vector<int> &faceshader,
@@ -1030,7 +1039,7 @@ void yafrayPluginRender_t::genCompleFace(vector<int> &faces,/*vector<string> &sh
faces.push_back(idx1); faces.push_back(idx2); faces.push_back(idx3);
if (has_uv) genUVcoords(uvcoords, vlr, uvc, true);
- if (EXPORT_VCOL) genVcol(vcol, vlr, 2, 3, 0);
+ if (EXPORT_VCOL) genVcol(vcol, vlr, true);
}
void yafrayPluginRender_t::genVertices(vector<yafray::point3d_t> &verts, int &vidx,
@@ -1420,7 +1429,6 @@ void yafrayPluginRender_t::writeLamps()
}
}
-
// write main camera
void yafrayPluginRender_t::writeCamera()
{
@@ -1432,10 +1440,11 @@ void yafrayPluginRender_t::writeCamera()
params["type"] = yafray::parameter_t("perspective");
params["resx"]=yafray::parameter_t(R.r.xsch);
params["resy"]=yafray::parameter_t(R.r.ysch);
- float aspect = 1;
- 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));
+ float f_aspect = 1;
+ if ((R.r.xsch*R.r.xasp)<=(R.r.ysch*R.r.yasp)) f_aspect = float(R.r.xsch*R.r.xasp)/float(R.r.ysch*R.r.yasp);
+ params["focal"] = yafray::parameter_t(mainCamLens/(f_aspect*32.f));
+ params["aspect_ratio"] = yafray::parameter_t(R.ycor);
// dof params, only valid for real camera
if (maincam_obj->type==OB_CAMERA) {
@@ -1446,6 +1455,28 @@ void yafrayPluginRender_t::writeCamera()
params["use_qmc"] = yafray::parameter_t("off");
else
params["use_qmc"] = yafray::parameter_t("on");
+ // bokeh params
+ string st = "disk1";
+ if (cam->YF_bkhtype==1)
+ st = "disk2";
+ else if (cam->YF_bkhtype==2)
+ st = "triangle";
+ else if (cam->YF_bkhtype==3)
+ st = "square";
+ else if (cam->YF_bkhtype==4)
+ st = "pentagon";
+ else if (cam->YF_bkhtype==5)
+ st = "hexagon";
+ else if (cam->YF_bkhtype==6)
+ st = "ring";
+ params["bokeh_type"] = yafray::parameter_t(st);
+ st = "uniform";
+ if (cam->YF_bkhbias==1)
+ st = "center";
+ else if (cam->YF_bkhbias==2)
+ st = "edge";
+ params["bokeh_bias"] = yafray::parameter_t(st);
+ params["bokeh_rotation"] = yafray::parameter_t(cam->YF_bkhrot);
}
params["from"]=yafray::parameter_t(
diff --git a/source/blender/yafray/intern/export_Plugin.h b/source/blender/yafray/intern/export_Plugin.h
index d2d9128d824..7dbcdfbe7fc 100644
--- a/source/blender/yafray/intern/export_Plugin.h
+++ b/source/blender/yafray/intern/export_Plugin.h
@@ -47,8 +47,7 @@ class yafrayPluginRender_t : public yafrayRender_t
virtual bool finishExport();
void genUVcoords(std::vector<yafray::GFLOAT> &uvcoords,VlakRen *vlr,TFace* uvc, bool comple=false);
- void genVcol(std::vector<yafray::CFLOAT> &vcol,VlakRen *vlr,
- int p1,int p2,int p3);
+ void genVcol(std::vector<yafray::CFLOAT> &vcol, VlakRen *vlr, bool comple=false);
void genFace(std::vector<int> &faces,std::vector<std::string> &shaders,std::vector<int> &faceshader,
std::vector<yafray::GFLOAT> &uvcoords,std::vector<yafray::CFLOAT> &vcol,
std::map<VertRen*, int> &vert_idx,VlakRen *vlr,
diff --git a/source/blender/yafray/intern/yafray_Render.cpp b/source/blender/yafray/intern/yafray_Render.cpp
index bbb5855b964..c0bf86b1840 100644
--- a/source/blender/yafray/intern/yafray_Render.cpp
+++ b/source/blender/yafray/intern/yafray_Render.cpp
@@ -70,18 +70,6 @@ bool yafrayRender_t::exportScene()
}
-// find object by name in global scene (+'OB'!)
-Object* yafrayRender_t::findObject(const char* name)
-{
- Base* bs = (Base*)G.scene->base.first;
- while (bs) {
- Object* obj = bs->object;
- if (!strcmp(name, obj->id.name)) return obj;
- bs = bs->next;
- }
- return NULL;
-}
-
// gets all unique face materials & textures,
// and sorts the facelist rejecting anything that is not a quad or tri,
// as well as associating them again with the original Object.
diff --git a/source/blender/yafray/intern/yafray_Render.h b/source/blender/yafray/intern/yafray_Render.h
index e5c710c465d..b14b19a568f 100644
--- a/source/blender/yafray/intern/yafray_Render.h
+++ b/source/blender/yafray/intern/yafray_Render.h
@@ -74,9 +74,7 @@ class yafrayRender_t
// mtds
bool exportScene();
-
void addDupliMtx(Object* obj);
-
bool objectKnownData(Object* obj);
protected:
@@ -95,7 +93,6 @@ class yafrayRender_t
std::map<Image*, Material*> imagetex;
std::map<Image*, std::string> imgtex_shader;
- Object* findObject(const char* name);
bool getAllMatTexObs();
virtual void writeTextures()=0;