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.
This commit is contained in:
Alfredo de Greef 2005-05-27 17:52:53 +00:00
parent f5435d924b
commit cf8d9fbb10
11 changed files with 143 additions and 103 deletions

View File

@ -72,7 +72,7 @@ typedef struct Lamp {
short YF_phdepth, YF_useqmc, YF_bufsize, YF_pad;
float YF_causticblur, YF_ltradius;
/* yafray: glow params */
float YF_glowint;
float YF_glowint, YF_glowofs, YF_pad3;
short YF_glowtype, YF_pad2;
struct MTex *mtex[10];

View File

@ -103,12 +103,9 @@ typedef struct Material {
float fhdist, xyfrict;
short dynamode, pad2;
/* yafray: dispersion parameters */
float YF_er, YF_eg, YF_eb;
float YF_dpwr;
short YF_dsmp, YF_djit;
/* yafray: material preset menu */
short YF_preset, pad6;
/* yafray: absorption color, dispersion parameters and material preset menu */
float YF_ar, YF_ag, YF_ab, YF_dscale, YF_dpwr;
int YF_dsmp, YF_preset, YF_djit;
ScriptLink scriptlink;
} Material;

View File

@ -225,7 +225,7 @@ typedef struct RenderData {
/* yafray: global panel params. TODO: move elsewhere */
short GIquality, GIcache, GImethod, GIphotons, GIdirect;
short YF_AA, YFexportxml, YF_nobump, yfpad1[2];
short YF_AA, YFexportxml, YF_nobump, YF_clamprgb, yfpad1;
int GIdepth, GIcausdepth, GIpixelspersample;
int GIphotoncount, GImixphotons;
float GIphotonradius;

View File

@ -302,7 +302,7 @@ typedef struct LampRen
int YF_numphotons, YF_numsearch;
short YF_phdepth, YF_useqmc, YF_bufsize;
float YF_causticblur, YF_ltradius;
float YF_glowint;
float YF_glowint, YF_glowofs;
short YF_glowtype;
/* ray optim */

View File

@ -850,6 +850,10 @@ static void yafrayRender(void)
else
YAF_switchPlugin();
RE_local_init_render_display();
RE_local_clear_render_display(R.win);
RE_local_timecursor((G.scene->r.cfra));
printf("Starting scene conversion.\n");
prepareScene();
printf("Scene conversion done.\n");

View File

@ -1758,6 +1758,7 @@ void RE_add_render_lamp(Object *ob, int doshadbuf)
lar->YF_ltradius = la->YF_ltradius;
lar->YF_bufsize = la->YF_bufsize;
lar->YF_glowint = la->YF_glowint;
lar->YF_glowofs = la->YF_glowofs;
lar->YF_glowtype = la->YF_glowtype;
}

View File

@ -1279,16 +1279,17 @@ static void render_panel_yafrayGI()
if (G.scene->r.GImethod>0)
{
if (G.scene->r.GIdepth==0) G.scene->r.GIdepth=2;
if (G.scene->r.GImethod==2) {
uiDefButI(block, NUM, B_DIFF, "Depth:", 180,175,110,20, &G.scene->r.GIdepth, 1.0, 100.0, 10, 10, "Number of bounces of the indirect light");
uiDefButI(block, NUM, B_DIFF, "CDepth:", 180,150,110,20, &G.scene->r.GIcausdepth, 1.0, 100.0, 10, 10, "Number of bounces inside objects (for caustics)");
uiDefButS(block,TOG|BIT|0, B_REDR, "Photons",240,125,89,20, &G.scene->r.GIphotons, 0, 0, 0, 0, "Use global photons to help in GI");
uiDefButS(block,TOG|BIT|0, B_REDR, "Photons",210,125,100,20, &G.scene->r.GIphotons, 0, 0, 0, 0, "Use global photons to help in GI");
}
uiDefButS(block,TOG|BIT|0, B_REDR, "Cache",125,125,89,20, &G.scene->r.GIcache, 0, 0, 0, 0, "Cache occlusion/irradiance samples (faster)");
if (G.scene->r.GIcache)
uiDefButS(block,TOG|BIT|0, B_REDR, "NoBump",15,125,89,20, &G.scene->r.YF_nobump, 0, 0, 0, 0, "Don't use bumpnormals for cache (faster, but no bumpmapping in total indirectly lit areas)");
uiDefButS(block,TOG|BIT|0, B_REDR, "Cache",6,125,95,20, &G.scene->r.GIcache, 0, 0, 0, 0, "Cache occlusion/irradiance samples (faster)");
if (G.scene->r.GIcache)
{
uiDefButS(block,TOG|BIT|0, B_REDR, "NoBump",108,125,95,20, &G.scene->r.YF_nobump, 0, 0, 0, 0, "Don't use bumpnormals for cache (faster, but no bumpmapping in total indirectly lit areas)");
uiDefBut(block, LABEL, 0, "Cache parameters:", 5,105,130,20, 0, 1.0, 0, 0, 0, "");
if (G.scene->r.GIshadowquality==0.0) G.scene->r.GIshadowquality=0.9;
uiDefButF(block, NUM, B_DIFF,"ShadQu:", 5,85,154,20, &(G.scene->r.GIshadowquality), 0.01, 1.0 ,1,0, "Sets the shadow quality, keep it under 0.95 :-) ");
@ -1297,6 +1298,7 @@ static void render_panel_yafrayGI()
if (G.scene->r.GIrefinement==0) G.scene->r.GIrefinement=1.0;
uiDefButF(block, NUM, B_DIFF, "Ref:", 84,60,75,20, &G.scene->r.GIrefinement, 0.001, 1.0, 1, 0, "Threshold to refine shadows EXPERIMENTAL. 1 = no refinement");
}
if (G.scene->r.GImethod==2) {
if (G.scene->r.GIphotons)
{
@ -1314,6 +1316,7 @@ static void render_panel_yafrayGI()
0, 0, 0, 0, "Show the photonmap directly in the render for tuning");
}
}
}
}
@ -1329,6 +1332,9 @@ static void render_panel_yafrayGlobal()
// label to force a boundbox for buttons not to be centered
uiDefBut(block, LABEL, 0, " ", 305,180,10,10, 0, 0, 0, 0, 0, "");
uiDefButS(block,TOGN|BIT|0, B_REDR, "xml", 5,180,75,20, &G.scene->r.YFexportxml,
0, 0, 0, 0, "Export to an xml file and call yafray instead of plugin");
uiDefButF(block, NUMSLI, B_DIFF,"Bi ", 5,35,150,20, &(G.scene->r.YF_raybias),
0.0, 10.0 ,0,0, "Shadow ray bias to avoid self shadowing");
uiDefButI(block, NUM, B_DIFF, "Raydepth ", 5,60,150,20,
@ -1336,15 +1342,12 @@ static void render_panel_yafrayGlobal()
uiDefButF(block, NUMSLI, B_DIFF, "Gam ", 5,10,150,20, &G.scene->r.YF_gamma, 0.001, 5.0, 0, 0, "Gamma correction, 1 is off");
uiDefButF(block, NUMSLI, B_DIFF, "Exp ", 160,10,150,20,&G.scene->r.YF_exposure, 0.0, 10.0, 0, 0, "Exposure adjustment, 0 is off");
uiDefButI(block, NUM, B_DIFF, "Processors:", 160,35,150,20,
&G.scene->r.YF_numprocs, 1.0, 8.0, 10, 10, "Number of processors to use");
uiDefButI(block, NUM, B_DIFF, "Processors:", 160,60,150,20, &G.scene->r.YF_numprocs, 1.0, 8.0, 10, 10, "Number of processors to use");
/*AA Settings*/
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,140,75,20, &G.scene->r.YFexportxml,
0, 0, 0, 0, "Export to an xml file and call yafray instead of plugin");
uiDefButS(block, TOGN|BIT|0, B_DIFF, "Clamp RGB", 160,140,150,20, &G.scene->r.YF_clamprgb, 1.0, 8.0, 10, 10, "For AA on fast high contrast changes. Not advisable for Bokeh! Dulls lens shape detail.");
if(G.scene->r.YF_AA){
uiDefButI(block, NUM, B_DIFF, "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, B_DIFF, "AA Samples ", 160,115,150,20, &G.scene->r.YF_AAsamples, 0, 2048, 10, 10, "Number of samples per pass");

View File

@ -2297,8 +2297,9 @@ static void lamp_panel_yafray(Object *ob, Lamp *la)
/* to prevent clash with blender shadowbuf flag, a special flag is used for yafray */
if (la->type==LA_LOCAL) {
uiDefButS(block, TOG|BIT|14, B_SHADBUF, "Buf.Shadow",10,160,80,19,&la->mode, 0, 0, 0, 0, "Lets light produce shadows using shadow buffer");
uiDefButF(block, NUM, B_DIFF, "GlowInt:", 100,155,200,19, &la->YF_glowint, 0.0, 1.0, 1, 0, "Sets light glow intensity, 0 is off");
uiDefButS(block, NUM, B_DIFF, "GlowType:", 100,135,200,19, &la->YF_glowtype, 0, 1, 1, 0, "Sets light glow type");
uiDefButF(block, NUM, B_DIFF, "GloInt:", 100,155,200,19, &la->YF_glowint, 0.0, 1.0, 1, 0, "Sets light glow intensity, 0 is off");
uiDefButF(block, NUM, B_DIFF, "GloOfs:", 100,135,100,19, &la->YF_glowofs, 0.0, 2.0, 1, 0, "Sets light glow offset, the higher, the less 'peaked' the glow");
uiDefButS(block, NUM, B_DIFF, "GlowType:", 200,135,100,19, &la->YF_glowtype, 0, 1, 1, 0, "Sets light glow type");
}
/* shadowbuffers used only for 'softlight' & spotlight with halo */
@ -2910,7 +2911,7 @@ static void material_panel_tramir_yafray(Material *ma)
/* material preset menu */
uiDefBut(block, LABEL, 0, "Mat.Preset", 20, 182, 100, 20, 0, 0.0, 0.0, 0, 0, "");
uiDefButS(block, MENU, B_MAT_YF_PRESET, mstr, 110, 182, 200, 20, &ma->YF_preset, 0.0, 0.0, 0, 0, "Quick material presets to start with");
uiDefButI(block, MENU, B_MAT_YF_PRESET, mstr, 110, 182, 200, 20, &ma->YF_preset, 0.0, 0.0, 0, 0, "Basic material presets to start with");
uiDefButI(block, TOG|BIT|18, B_MATPRV,"Ray Mirror", 10,160,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for mirror reflection rendering");
uiDefButI(block, TOG|BIT|17, B_MATRAYTRANSP,"Ray Transp", 110,160,100,20, &(ma->mode), 0, 0, 0, 0, "Enables raytracing for transparency rendering");
@ -2920,22 +2921,23 @@ static void material_panel_tramir_yafray(Material *ma)
uiDefButF(block, NUMSLI, B_MATPRV, "frsOfs ", 160,140,150,20, &(ma->fresnel_mir_i), 1.0, 5.0, 10, 2, "Fresnel offset, 1 is uniform mirror, 5 is fresnel mirror (IOR>1)");
/* ior has extended range up to 30, for use with total fresnel reflection */
uiDefButF(block, NUMSLI, B_MATPRV, "IOR ", 10,110,150,20, &(ma->ang), 1.0, 30.0, 100, 2, "Sets the angular index of refraction for raytrace");
uiDefButF(block, NUMSLI, B_MATPRV, "IOR ", 10,115,150,20, &(ma->ang), 1.0, 30.0, 100, 2, "Sets the angular index of refraction for raytrace");
if(ma->mode & MA_RAYTRANSP)
uiDefButF(block, NUM, B_MATPRV, "Filt:", 160,110,150,20, &(ma->filter), 0.0, 1.0, 10, 0, "Amount of filtering for transparent raytrace");
uiDefButF(block, NUM, B_MATPRV, "Filt:", 160,115,150,20, &(ma->filter), 0.0, 1.0, 10, 0, "Amount of filtering for transparent raytrace");
/* extinction color */
uiDefBut(block, LABEL, 0, "Ext.Color", 10, 80, 150, 19, 0, 0.0, 0.0, 0, 0, "");
uiDefButF(block, COL, B_MATPRV_DRAW, "", 10, 20, 30, 58, &ma->YF_er, 0, 0, 0, B_MATCOL, "transmit extinction color, black is no extinction");
uiDefButF(block, NUMSLI, B_MATPRV, "eR ", 40, 60, 120, 18, &ma->YF_er, 0.0, 1.0, B_MATCOL, 0, "");
uiDefButF(block, NUMSLI, B_MATPRV, "eG ", 40, 40, 120, 18, &ma->YF_eg, 0.0, 1.0, B_MATCOL, 0, "");
uiDefButF(block, NUMSLI, B_MATPRV, "eB ", 40, 20, 120, 18, &ma->YF_eb, 0.0, 1.0, B_MATCOL, 0, "");
/* absorption color */
uiDefBut(block, LABEL, 0, "Absorption Color", 10, 98, 150, 18, 0, 0.0, 0.0, 0, 0, "");
uiDefButF(block, COL, B_MATPRV_DRAW, "", 10, 38, 30, 58, &ma->YF_ar, 0, 0, 0, B_MATCOL, "transmit absorption color, white is no absorption");
uiDefButF(block, NUMSLI, B_MATPRV, "aR ", 40, 78, 120, 18, &ma->YF_ar, 1e-7f, 1.0, B_MATCOL, 0, "");
uiDefButF(block, NUMSLI, B_MATPRV, "aG ", 40, 58, 120, 18, &ma->YF_ag, 1e-7f, 1.0, B_MATCOL, 0, "");
uiDefButF(block, NUMSLI, B_MATPRV, "aB ", 40, 38, 120, 18, &ma->YF_ab, 1e-7f, 1.0, B_MATCOL, 0, "");
uiDefButF(block, NUM, B_MATPRV, "Ds", 10, 18, 150, 18, &ma->YF_dscale, 1e-7f, 100.0, 10.0, 0, "absorption distance scale, 1 is one blender (world) unit of distance");
/* disperions parameters */
uiDefBut(block, LABEL, 0, "Dispersion", 160, 80, 150, 18, 0, 0.0, 0.0, 0, 0, "");
uiDefButF(block, NUM, B_MATPRV, "Pwr ", 160, 60, 150, 18, &ma->YF_dpwr, 0.0, 1.0, 0.25, 0, "Dispersion power, the higher, the more dispersion, 0 is no dispersion");
uiDefButS(block, NUM, B_MATPRV, "Samples ", 160, 40, 150, 18, &ma->YF_dsmp, 1.0, 100.0, 0, 0, "Dispersion samples, minimum at least 10, unless using jitter ");
uiDefButS(block, TOG|BIT|0, B_MATPRV, "Jitter", 160, 20, 150, 18, &ma->YF_djit, 0.0, 1.0, 0, 0, "Enable jittering of wavelenghts, adds noise");
uiDefBut(block, LABEL, 0, "Dispersion", 160, 98, 150, 18, 0, 0.0, 0.0, 0, 0, "");
uiDefButF(block, NUM, B_MATPRV, "Pwr ", 160, 78, 150, 18, &ma->YF_dpwr, 0.0, 1.0, 0.25, 0, "Dispersion power, the higher, the more dispersion, 0 is no dispersion");
uiDefButI(block, NUM, B_MATPRV, "Samples ", 160, 58, 150, 18, &ma->YF_dsmp, 1.0, 100.0, 0, 0, "Dispersion samples, minimum at least 10, unless using jitter ");
uiDefButI(block, TOG|BIT|0, B_MATPRV, "Jitter", 160, 38, 150, 18, &ma->YF_djit, 0.0, 1.0, 0, 0, "Enable jittering of wavelenghts, adds noise");
}
@ -3262,8 +3264,13 @@ void material_panels()
material_panel_shading(ma);
if (G.scene->r.renderer==R_INTERN)
material_panel_tramir(ma);
else
else {
if (ma->YF_ar==0.f) {
ma->YF_ar = ma->YF_ag = ma->YF_ab = 1;
ma->YF_dscale = 1;
}
material_panel_tramir_yafray(ma);
}
material_panel_texture(ma);
mtex= ma->mtex[ ma->texact ];

View File

@ -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;
}
}

View File

@ -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;
}

View File

@ -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..