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 /source/blender/yafray
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.
Diffstat (limited to 'source/blender/yafray')
-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
5 files changed, 117 insertions, 80 deletions
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;