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>2005-05-27 21:52:53 +0400
committerAlfredo de Greef <eeshlo@yahoo.com>2005-05-27 21:52:53 +0400
commitcf8d9fbb109af234fc0fd3fc7b147d19c76f0d27 (patch)
treed28c07a12622f6265f7e9d24d5be4d50ffcf46f6 /source/blender/yafray
parentf5435d924ba172261070826ee67f38f112270679 (diff)
Added some backward compatibility with old yafray blendershader. Because of missing
parameters the material preset menu won't be as useful. Both glass presets will look the same because there is no 'filter' parameter in the old yafray for instance. So using the new Blender version with an old yafray version should work a bit better, though the other way around, using the new yafray with an old blender version, will generally not work as well. I added a few extra things. In 'yafray' panel re-arranged some buttons, and added a new button 'Clamp RGB'. This button will be enabled by default and helps to improve AA on high contrast edges in the image. When using bokeh however, it is best to switch this off, otherwise lens shaped highlights will be quite a bit less visible. Changed the 'extinction' parameter name to the probably more correct term 'absorption', though mathematically it works out the same. Also changed the behaviour of this color, it no longer specifies a color that will be removed as I wrote in the previous commit, but instead the actual color at one (blender) unit of distance. The 'Ds' (distance scale) button below the color sliders controls the scaling of this unit distance. What this means is that if you take the standard blender cube, which covers two units of distance by default, setting the distance scale button to 2.0 will make sure that the color you specified is exactly that color at that distance (provided the base color itself is white of course, or 'filter' is 0, otherwise it will be filtered by the base color too). Beyond this distance the color will get darker. The glow option for point/soft/sphere lights has a new parameter 'GloOfs', or glow offset. Setting this to a higher value then 0 will soften the central peak of the glow. Another unreported bug fix: For xml export, when yafray failed to render the xml file for some unknown reason, or because of other problems, the export code would still load the previously rendered image, this causes problems however if the image resolution is not the same as the current Blender buffer, and so could cause memory corruption or crashes. This is now taken into account. World image backgrounds now use the blender mapping settings as well, but only the 'AngMap', 'Sphere' and 'Tube' settings. But in yafray those last two, unlike Blender, cover the whole view, not just the upper half, so is not really fully compatible with yafray. So now you have to set one of these buttons too when loading a hdr lightprobe image. btw, something I forgot to mention in previous commits is that the exposure control using the texture brightness slider is no longer restricted to integer values. It is now a floating point value, so you're not restricted to the 0 1 and 2 slider positions anymore, anything in between will work too. And finally, display updating is now more like Blender, using the mouse cursor as frame counter for animation, etc.
Diffstat (limited to 'source/blender/yafray')
-rwxr-xr-xsource/blender/yafray/intern/export_File.cpp93
-rw-r--r--source/blender/yafray/intern/export_Plugin.cpp71
-rw-r--r--source/blender/yafray/intern/yafray_Render.cpp2
3 files changed, 97 insertions, 69 deletions
diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp
index 9badc0c5eff..272c830d7b7 100755
--- a/source/blender/yafray/intern/export_File.cpp
+++ b/source/blender/yafray/intern/export_File.cpp
@@ -220,7 +220,8 @@ bool yafrayFileRender_t::writeRender()
ostr << "\tAA_passes=\"" << passes << "\" AA_minsamples=\"" << minsamples << "\"\n";
}
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 << "\tAA_pixelwidth=\"1.5\" AA_threshold=\"0.05\" bias=\"" << R.r.YF_raybias
+ << "\" clamp_rgb=\"" << ((R.r.YF_clamprgb==0) ? "on" : "off") << "\"\n";
}
World *world = G.scene->world;
@@ -277,6 +278,12 @@ void yafrayFileRender_t::displayImage()
fread(&header, 1, 18, fp);
unsigned short width = (unsigned short)(header[12] + (header[13]<<8));
unsigned short height = (unsigned short)(header[14] + (header[15]<<8));
+ // don't do anything if resolution doesn't match that of rectot
+ if ((width!=R.rectx) || (height!=R.recty)) {
+ fclose(fp);
+ fp = NULL;
+ return;
+ }
unsigned char byte_per_pix = (unsigned char)(header[16]>>3);
// read past any id (none in this case though)
unsigned int idlen = (unsigned int)header[0];
@@ -672,7 +679,9 @@ void yafrayFileRender_t::writeShader(const string &shader_name, Material* matr,
// reflection/refraction
if ( (matr->mode & MA_RAYMIRROR) || (matr->mode & MA_RAYTRANSP) )
ostr << "\t\t<IOR value=\"" << matr->ang << "\" />\n";
- if (matr->mode & MA_RAYMIRROR) {
+
+ if (matr->mode & MA_RAYMIRROR)
+ {
// Sofar yafray's min_refle parameter (which misleadingly actually controls fresnel reflection offset)
// has been mapped to Blender's ray_mirror parameter.
// This causes it be be misinterpreted and misused as a reflection amount control however.
@@ -683,19 +692,37 @@ void yafrayFileRender_t::writeShader(const string &shader_name, Material* matr,
ostr << "\t\t<reflect_amount value=\""<< matr->ray_mirror << "\" />\n";
float fo = 1.f-(matr->fresnel_mir_i-1.f)*0.25f; // blender param range [1,5], also here reversed (1 in Blender -> no fresnel)
ostr << "\t\t<fresnel_offset value=\""<< fo << "\" />\n";
- // transmit extinction color
- ostr << "\t\t<extinction r=\"" << matr->YF_er << "\" g=\"" << matr->YF_eg << "\" b=\"" << matr->YF_eb << "\" />\n";
+ // transmit absorption color
+ // to make things easier(?) for user it now specifies the actual color at 1 unit / YF_dscale of distance
+ const float maxlog = -log(1e-38);
+ float ar = (matr->YF_ar>0) ? -log(matr->YF_ar) : maxlog;
+ float ag = (matr->YF_ag>0) ? -log(matr->YF_ag) : maxlog;
+ float ab = (matr->YF_ab>0) ? -log(matr->YF_ab) : maxlog;
+ float sc = matr->YF_dscale;
+ if (sc!=0.f) sc=1.f/sc;
+ ostr << "\t\t<absorption r=\"" << ar*sc << "\" g=\"" << ag*sc << "\" b=\"" << ab*sc << "\" />\n";
// dispersion
ostr << "\t\t<dispersion_power value=\"" << matr->YF_dpwr << "\" />\n";
ostr << "\t\t<dispersion_samples value=\"" << matr->YF_dsmp << "\" />\n";
ostr << "\t\t<dispersion_jitter value=\"" << (matr->YF_djit ? "on" : "off") << "\" />\n";
+
+ // for backward compatibility, also add old 'reflected' parameter, copy of mirror_color
+ ostr << "\t\t<reflected r=\"" << matr->mirr << "\" g=\"" << matr->mirg << "\" b=\"" << matr->mirb << "\" />\n";
+ // same for 'min_refle' param. Instead of the ray_mirror parameter that was used before, since now
+ // the parameter's function is taken over by the fresnel offset parameter, use that instead.
+ ostr << "\t\t<min_refle value=\"" << fo << "\" />\n";
+
}
+
if (matr->mode & MA_RAYTRANSP)
{
ostr << "\t\t<refract value=\"on\" />\n";
ostr << "\t\t<transmit_filter value=\"" << matr->filter << "\" />\n";
// tir on by default
ostr << "\t\t<tir value=\"on\" />\n";
+ // for backward compatibility, also add old 'transmitted' parameter, copy of 'color' * (1-alpha)
+ float na = 1.f-matr->alpha;
+ ostr << "\t\t<transmitted r=\"" << matr->r*na << "\" g=\"" << matr->g*na << "\" b=\"" << matr->b*na << "\" />\n";
}
string Mmode = "";
@@ -1509,23 +1536,24 @@ void yafrayFileRender_t::writeLamps()
if (lamp->type==LA_LOCAL) {
if (lamp->mode & LA_YF_SOFT) {
// shadowmapped omnidirectional light
- ostr << "softlight";
+ ostr << "softlight\"";
is_softL = true;
}
else if ((lamp->mode & LA_SHAD_RAY) && (lamp->YF_ltradius>0.0)) {
// area sphere, only when ray shadows enabled and radius>0.0
- ostr << "spherelight";
+ ostr << "spherelight\"";
is_sphereL = true;
}
- else ostr << "pointlight";
- ostr << "\" glow_intensity=\"" << lamp->YF_glowint << "\" glow_type=\"" << lamp->YF_glowtype << "\"";
+ else ostr << "pointlight\"";
+ ostr << " glow_intensity=\"" << lamp->YF_glowint << "\" glow_offset=\"" << lamp->YF_glowofs
+ << "\" glow_type=\"" << lamp->YF_glowtype << "\"";
}
else if (lamp->type==LA_SPOT)
- ostr << "spotlight";
+ ostr << "spotlight\"";
else if ((lamp->type==LA_SUN) || (lamp->type==LA_HEMI)) // hemi exported as sun
- ostr << "sunlight";
+ ostr << "sunlight\"";
else if (lamp->type==LA_YF_PHOTON)
- ostr << "photonlight";
+ ostr << "photonlight\"";
else {
// possibly unknown type, ignore
cout << "Unknown Blender lamp type: " << lamp->type << endl;
@@ -1839,36 +1867,25 @@ bool yafrayFileRender_t::writeWorld()
MTex* wtex = world->mtex[i];
if (!wtex) continue;
Image* wimg = wtex->tex->ima;
+ // now always exports if image used as world texture
if ((wtex->tex->type==TEX_IMAGE) && (wimg!=NULL)) {
string wt_path = wimg->name;
adjustPath(wt_path);
- if (BLI_testextensie(wimg->name, ".hdr")) {
- ostr.str("");
- ostr << "<background type=\"image\" name=\"world_background\" ";
- // exposure_adjust not restricted to integer range anymore
- ostr << "exposure_adjust=\"" << wtex->tex->bright-1.f << "\" mapping=\"probe\" >\n";
- ostr << "\t<filename value=\"" << wt_path << "\" />\n";
- ostr << "\t<interpolate value=\"" << ((wtex->tex->imaflag & TEX_INTERPOL) ? "bilinear" : "none") << "\" />\n";
- ostr << "</background>\n\n";
- xmlfile << ostr.str();
- return true;
- }
- else if (BLI_testextensie(wimg->name, ".jpg") || BLI_testextensie(wimg->name, ".jpeg") || BLI_testextensie(wimg->name, ".tga")) {
- ostr.str("");
- ostr << "<background type=\"image\" name=\"world_background\" >\n";
- /*
- // not yet in yafray, always assumes spheremap for now, not the same as in Blender,
- // which for some reason is scaled by 2 in Blender???
- if (wtex->texco & TEXCO_ANGMAP)
- ostr << " mapping=\"probe\" >\n";
- else
- ostr << " mapping=\"sphere\" >\n";
- */
- ostr << "\t<filename value=\"" << wt_path << "\" />\n";
- ostr << "</background>\n\n";
- xmlfile << ostr.str();
- return true;
- }
+ ostr.str("");
+ ostr << "<background type=\"image\" name=\"world_background\" ";
+ // exposure_adjust not restricted to integer range anymore
+ ostr << "exposure_adjust=\"" << wtex->tex->bright-1.f << "\"";
+ if (wtex->texco & TEXCO_ANGMAP)
+ ostr << " mapping=\"probe\" >\n";
+ else if (wtex->texco & TEXCO_H_SPHEREMAP) // in yafray full sphere
+ ostr << " mapping=\"sphere\" >\n";
+ else // assume 'tube' for anything else
+ ostr << " mapping=\"tube\" >\n";
+ ostr << "\t<filename value=\"" << wt_path << "\" />\n";
+ ostr << "\t<interpolate value=\"" << ((wtex->tex->imaflag & TEX_INTERPOL) ? "bilinear" : "none") << "\" />\n";
+ ostr << "</background>\n\n";
+ xmlfile << ostr.str();
+ return true;
}
}
diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp
index 9b4dc856f2f..886198c7be3 100644
--- a/source/blender/yafray/intern/export_Plugin.cpp
+++ b/source/blender/yafray/intern/export_Plugin.cpp
@@ -253,7 +253,7 @@ bool yafrayPluginRender_t::writeRender()
params["background_name"] = yafray::parameter_t("world_background");
}
params["bias"]=yafray::parameter_t(R.r.YF_raybias);
- //params["outfile"]=yafray::parameter_t(imgout);
+ params["clamp_rgb"] = yafray::parameter_t((R.r.YF_clamprgb==0) ? "on" : "off");
blenderYafrayOutput_t output;
yafrayGate->render(params,output);
cout<<"render finished"<<endl;
@@ -666,6 +666,7 @@ void yafrayPluginRender_t::writeShader(const string &shader_name, Material* matr
// reflection/refraction
if ( (matr->mode & MA_RAYMIRROR) || (matr->mode & MA_RAYTRANSP) )
params["IOR"] = yafray::parameter_t(matr->ang);
+
if (matr->mode & MA_RAYMIRROR)
{
// Sofar yafray's min_refle parameter (which misleadingly actually controls fresnel reflection offset)
@@ -678,19 +679,37 @@ void yafrayPluginRender_t::writeShader(const string &shader_name, Material* matr
params["reflect_amount"] = yafray::parameter_t(matr->ray_mirror);
float fo = 1.f-(matr->fresnel_mir_i-1.f)*0.25f; // blender param range [1,5], also here reversed (1 in Blender -> no fresnel)
params["fresnel_offset"] = yafray::parameter_t(fo);
- // transmit extinction color
- params["extinction"] = yafray::parameter_t(yafray::color_t(matr->YF_er, matr->YF_eg, matr->YF_eb));
+ // transmit absorption color
+ // to make things easier(?) for user it now specifies the actual color at 1 unit / YF_dscale of distance
+ const float maxlog = -log(1e-38);
+ float ar = (matr->YF_ar>0) ? -log(matr->YF_ar) : maxlog;
+ float ag = (matr->YF_ag>0) ? -log(matr->YF_ag) : maxlog;
+ float ab = (matr->YF_ab>0) ? -log(matr->YF_ab) : maxlog;
+ float sc = matr->YF_dscale;
+ if (sc!=0.f) sc=1.f/sc;
+ params["absorption"] = yafray::parameter_t(yafray::color_t(ar*sc, ag*sc, ab*sc));
// dispersion
params["dispersion_power"] = yafray::parameter_t(matr->YF_dpwr);
params["dispersion_samples"] = yafray::parameter_t(matr->YF_dsmp);
params["dispersion_jitter"] = yafray::parameter_t(matr->YF_djit ? "on" : "off");
+
+ // for backward compatibility, also add old 'reflected' parameter, copy of mirror_color
+ params["reflected"] = yafray::parameter_t(yafray::color_t(matr->mirr, matr->mirg, matr->mirb));
+ // same for 'min_refle' param. Instead of the ray_mirror parameter that was used before, since now
+ // the parameter's function is taken over by the fresnel offset parameter, use that instead.
+ params["min_refle"] = yafray::parameter_t(fo);
+
}
+
if (matr->mode & MA_RAYTRANSP)
{
params["refract"] = yafray::parameter_t("on");
params["transmit_filter"] = yafray::parameter_t(matr->filter);
// tir on by default
params["tir"] = yafray::parameter_t("on");
+ // for backward compatibility, also add old 'transmitted' parameter, copy of 'color' * (1-alpha)
+ float na = 1.f-matr->alpha;
+ params["transmitted"] = yafray::parameter_t(yafray::color_t(matr->r*na, matr->g*na, matr->b*na));
}
string Mmode = "";
@@ -1500,6 +1519,7 @@ void yafrayPluginRender_t::writeLamps()
}
else params["type"] = yafray::parameter_t("pointlight");
params["glow_intensity"] = yafray::parameter_t(lamp->YF_glowint);
+ params["glow_offset"] = yafray::parameter_t(lamp->YF_glowofs);
params["glow_type"] = yafray::parameter_t(lamp->YF_glowtype);
}
else if (lamp->type==LA_SPOT)
@@ -1840,35 +1860,24 @@ bool yafrayPluginRender_t::writeWorld()
MTex* wtex = world->mtex[i];
if (!wtex) continue;
Image* wimg = wtex->tex->ima;
+ // now always exports if image used as world texture
if ((wtex->tex->type==TEX_IMAGE) && (wimg!=NULL)) {
string wt_path = wimg->name;
adjustPath(wt_path);
- if (BLI_testextensie(wimg->name, ".hdr")) {
- params["type"] = yafray::parameter_t("image");
- params["name"] = yafray::parameter_t("world_background");
- // exposure_adjust not restricted to integer range anymore
- params["exposure_adjust"] = yafray::parameter_t(wtex->tex->bright-1.f);
+ params["type"] = yafray::parameter_t("image");
+ params["name"] = yafray::parameter_t("world_background");
+ // exposure_adjust not restricted to integer range anymore
+ params["exposure_adjust"] = yafray::parameter_t(wtex->tex->bright-1.f);
+ if (wtex->texco & TEXCO_ANGMAP)
params["mapping"] = yafray::parameter_t("probe");
- params["filename"] = yafray::parameter_t(wt_path);
- params["interpolate"] = yafray::parameter_t((wtex->tex->imaflag & TEX_INTERPOL) ? "bilinear" : "none");
- yafrayGate->addBackground(params);
- return true;
- }
- else if (BLI_testextensie(wimg->name, ".jpg") || BLI_testextensie(wimg->name, ".jpeg") || BLI_testextensie(wimg->name, ".tga")) {
- params["type"] = yafray::parameter_t("image");
- params["name"] = yafray::parameter_t("world_background");
- /*
- // not yet in yafray, always assumes spheremap for now, not the same as in Blender,
- // which for some reason is scaled by 2 in Blender???
- if (wtex->texco & TEXCO_ANGMAP)
- params["mapping"] = yafray::parameter_t("probe");
- else
- params["mapping"] = yafray::parameter_t("sphere");
- */
- params["filename"] = yafray::parameter_t(wt_path);
- yafrayGate->addBackground(params);
- return true;
- }
+ else if (wtex->texco & TEXCO_H_SPHEREMAP) // in yafray full sphere
+ params["mapping"] = yafray::parameter_t("sphere");
+ else // assume 'tube' for anything else
+ params["mapping"] = yafray::parameter_t("tube");
+ params["filename"] = yafray::parameter_t(wt_path);
+ params["interpolate"] = yafray::parameter_t((wtex->tex->imaflag & TEX_INTERPOL) ? "bilinear" : "none");
+ yafrayGate->addBackground(params);
+ return true;
}
}
@@ -1926,10 +1935,10 @@ bool blenderYafrayOutput_t::putPixel(int x, int y, const yafray::color_t &c,
out++;
if (out==4096)
{
- RE_local_render_display(0,R.recty-1, R.rectx, R.recty, R.rectot);
+ RE_local_render_display(0, R.recty-1, R.rectx, R.recty, R.rectot);
out = 0;
}
- if (RE_local_test_break())
- return false;
+
+ if (RE_local_test_break()) return false;
return true;
}
diff --git a/source/blender/yafray/intern/yafray_Render.cpp b/source/blender/yafray/intern/yafray_Render.cpp
index 18a12e14ae4..c6a588110c3 100644
--- a/source/blender/yafray/intern/yafray_Render.cpp
+++ b/source/blender/yafray/intern/yafray_Render.cpp
@@ -115,6 +115,8 @@ bool yafrayRender_t::getAllMatTexObs()
(txtp==TEX_MAGIC) ||
(txtp==TEX_PLUGIN) ||
(txtp==TEX_ENVMAP)) continue;
+ // if texture is stucci, only export if 'nor' enabled
+ if ((txtp==TEX_STUCCI) && !((mx->mapto & MAP_NORM) || (mx->maptoneg & MAP_NORM))) continue;
// In the case of an image texture, check that there is an actual image, otherwise ignore.
// Stupid error was here (...if (txtp & TEX_IMAGE)...),
// which happened to work sofar, but not anymore with the extended texture support..