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-23 02:46:17 +0400
committerAlfredo de Greef <eeshlo@yahoo.com>2005-05-23 02:46:17 +0400
commitec45bfc5b11f42a43444a9906cd6ee4e37d6c03c (patch)
treeb0b6978dea7a1025fced7b056fc7364e96e42e17 /source/blender/yafray/intern/export_File.cpp
parent563af2aac1a7bfe29068cdcf3e605cc0f4e79dba (diff)
Second and final commit for this version of the yafray export code (probably, you never know
of course...) Not quite complete, but due to lack of time as good as it will get for now. From the previous commit, forgot to report that basic fog is supported as well. Though because I had not much time to complete the code, it is sort of unfinished, and you will have to tweak parameters specifically for yafray again. It uses only the world horizon color, and only uses the Blender mist distance setting. Textures now support checker clip mode. Fixed possibly all 'duplilist non-empty' errors, though it could hide the real cause of the error. AA is no longer enabled automatically for certain GI quality settings, I thought it best to leave it to the user to decide. SkyDome GI mode now supports cache as well. There is a new option in the GI quality menu 'Use Blender AO settings', which will as it says use the most important AO settings for the skydome parameters. The only AO parameters used are 'Samples', 'Dist' and the random sampling switch, which unlike in Blender you might want to use more often, since the QMC sampling used in yafray can result in visible patterns or a dithering type look. 'Random' is not completely random in yafray however, it is actually jittered (stratified) sampling. Using an occlusion cache, doesn't necessarily mean that you will always get much shorter render times. As with 'full' GI and cache, one problem is bumpmaps, when using bump (or normal) maps, the sampling will be much more dense, using lots more rendertime. As a temporary fix there is a button 'NoBump', but this also has the side effect that in areas of total indirect light (or when used with SkyDome cache) no bumpmapping will be visible. It is therefor best used with some direct light as well. For SkyDome with cache, and strong bumpmapping it might actually not make much difference, since for low distance values you can usually get away with low sample values as well. The entire material panel is now replaced by another panel to show only the parameters important to yafray and add some new ones as well. Since lots of users (especially yafray beginners) have had problems getting certain material aspects right, there is now a material preset menu available to hopefully solve some of the most common "How do I do this? It doesn't work!" questions seen in various forums. Choosing an option from this menu will set the required parameters to default values for yafray, and you can work your way from there to tweak it something you want. Most buttons are copies of the same Blender parameters, with some variations. Just like Blender 'Ray Mirror' enables reflection, 'Ray Transp' enables refraction. You can use 'ZTransp' for materials that have texture maps with alpha channels. Again, same as Blender 'rayMir' sets the amount of reflection. Next button 'frsOfs' however controls fresnel offset, meaning that when this is set to 1, you will get no fresnel effect and when set to 5, reflection is totally determined by fresnel, which is important for realistic glass/metals/etc. IOR is self-explanatory (...), same as Blender. When you have 'Ray Transp' enabled, the blender 'filter' button will appear next to the IOR button. This has the same effect as in Blender. Below that there are some new parameters, 'Ext.Color' sets the extinction color for transparent materials. Usually, in real transparent materials, light loses some of it's energy the further it has to travel through the object. This effect can be simulated with this parameter. Thing to look out for is that it specifies the color which will be REMOVED after traveling through the object. What this means is that say you have a clear white glass sphere, and set the extinction color to a strong blue, the result will be a very yellow object when rendered. Next to the color sliders, there is another set of three parameters, with which you can enable color dispersion for transparent objects. 'Pwr' sets the amount of dispersion, the higher, the more dispersion (the more colorful the result). (For real world materials, this number can be found or derived from data in various glass catalogues) The 'Samples' button below that sets the number of samples used, minimum values are around 7-10, and for very strong dispersion you might need a lot more. As usual, this also means an increase in render time of course, but to simulate realistic materials, you shouldn't really need more than 25 samples. In addition to that, when using low sample numbers, but to still get a good spread of colors, you can enable the jitter button, but this will also add noise. Point/soft(point with shadowbuffer) or sphere lights (light with radius), have a new option to add a simple glow effect, so that lights can be made visible. NOTE: just like spotlight halo's, glow is not visible against the background, there must be another object behind it. Simplest solution is to use a large black shadeless plane behind your scene. The glow intensity can be set with the 'GlowInt' parameter (use very low values around 0.01 even lower), and you can choose from two different types with the 'GlowType' button (which don't look much different, but type 1 is probably better, type 0 faster). And that's it, with apologies for the still missing features and full support in general, but this will have to do for now.
Diffstat (limited to 'source/blender/yafray/intern/export_File.cpp')
-rwxr-xr-xsource/blender/yafray/intern/export_File.cpp126
1 files changed, 89 insertions, 37 deletions
diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp
index 90e05e627c5..9badc0c5eff 100755
--- a/source/blender/yafray/intern/export_File.cpp
+++ b/source/blender/yafray/intern/export_File.cpp
@@ -213,9 +213,8 @@ bool yafrayFileRender_t::writeRender()
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\"\n";
- else if ((R.r.mode & R_OSA) && (R.r.osa)) {
+ // removed the default AA settings for midquality GI, better leave it to user
+ 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 << "\"\n";
@@ -224,19 +223,20 @@ bool yafrayFileRender_t::writeRender()
ostr << "\tAA_pixelwidth=\"1.5\" AA_threshold=\"0.05\" bias=\"" << R.r.YF_raybias << "\"\n";
}
- if (hasworld) {
- World *world = G.scene->world;
- if (world->mode & WO_MIST) {
- ostr << "\tfog_density=\"" << world->mistdist << "\" ";
- ostr << "fog_color r=\"" << world->horr << "\" g=\"" << world->horg << "\" b=\"" << world->horb << "\"\n";
- }
- ostr << "\tbackground_name=\"world_background\"\n";
- }
+ World *world = G.scene->world;
+ if (world) ostr << "\tbackground_name=\"world_background\"\n";
// alpha channel render when RGBA button enabled
if (R.r.planes==R_PLANES32) ostr << "\n\tsave_alpha=\"on\"";
ostr << " >\n";
+ // basic fog
+ if (world && (world->mode & WO_MIST)) {
+ float fd = world->mistdist;
+ if (fd>0) fd=1.f/fd; else fd=1;
+ ostr << "\t<fog_density value=\"" << fd << "\" />\n";
+ ostr << "\t<fog_color r=\"" << world->horr << "\" g=\"" << world->horg << "\" b=\"" << world->horb << "\" />\n";
+ }
ostr << "\t<outfile value=\"" << imgout << "\" />\n";
ostr << "</render>\n\n";
@@ -659,8 +659,7 @@ void yafrayFileRender_t::writeShader(const string &shader_name, Material* matr,
ostr.str("");
ostr << "<shader type=\"blendershader\" name=\"" << shader_name << "\" >\n";
ostr << "\t<attributes>\n";
- float diff = 1; //matr->alpha;
- ostr << "\t\t<color r=\"" << matr->r*diff << "\" g=\"" << matr->g*diff << "\" b=\"" << matr->b*diff << "\" />\n";
+ ostr << "\t\t<color r=\"" << matr->r << "\" g=\"" << matr->g << "\" b=\"" << matr->b << "\" />\n";
ostr << "\t\t<specular_color r=\"" << matr->specr << "\" g=\"" << matr->specg << "\" b=\"" << matr->specb << "\" />\n";
ostr << "\t\t<mirror_color r=\"" << matr->mirr << "\" g=\"" << matr->mirg << "\" b=\"" << matr->mirb << "\" />\n";
ostr << "\t\t<diffuse_reflect value=\"" << matr->ref << "\" />\n";
@@ -674,8 +673,6 @@ void yafrayFileRender_t::writeShader(const string &shader_name, Material* matr,
if ( (matr->mode & MA_RAYMIRROR) || (matr->mode & MA_RAYTRANSP) )
ostr << "\t\t<IOR value=\"" << matr->ang << "\" />\n";
if (matr->mode & MA_RAYMIRROR) {
- // blender uses mir color for reflection as well
- //ostr << "\t\t<reflected r=\"" << matr->mirr << "\" g=\"" << matr->mirg << "\" b=\"" << matr->mirb << "\" />\n";
// 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.
@@ -686,11 +683,15 @@ 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";
+ // 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";
}
if (matr->mode & MA_RAYTRANSP)
{
- //float tr=1.0-matr->alpha;
- //ostr << "\t\t<transmitted r=\"" << matr->r*tr << "\" g=\"" << matr->g*tr << "\" b=\"" << matr->b*tr << "\" />\n";
ostr << "\t\t<refract value=\"on\" />\n";
ostr << "\t\t<transmit_filter value=\"" << matr->filter << "\" />\n";
// tir on by default
@@ -1040,6 +1041,14 @@ void yafrayFileRender_t::writeMaterialsAndModulators()
ostr << "\t\t<clipping value=\"clip\" />\n";
else if (tex->extend==TEX_CLIPCUBE)
ostr << "\t\t<clipping value=\"clipcube\" />\n";
+ else if (tex->extend==TEX_CHECKER) {
+ ostr << "\t\t<clipping value=\"checker\" />\n";
+ string ts = "";
+ if (tex->flag & TEX_CHECKER_ODD) ts += "odd";
+ if (tex->flag & TEX_CHECKER_EVEN) ts += " even";
+ ostr << "\t\t<checker_mode value=\"" << ts << "\" />\n";
+ ostr << "\t\t<checker_dist value=\"" << tex->checkerdist << "\" />\n";
+ }
else
ostr << "\t\t<clipping value=\"repeat\" />\n";
@@ -1509,6 +1518,7 @@ void yafrayFileRender_t::writeLamps()
is_sphereL = true;
}
else ostr << "pointlight";
+ ostr << "\" glow_intensity=\"" << lamp->YF_glowint << "\" glow_type=\"" << lamp->YF_glowtype << "\"";
}
else if (lamp->type==LA_SPOT)
ostr << "spotlight";
@@ -1523,7 +1533,7 @@ void yafrayFileRender_t::writeLamps()
}
//no name available here, create one
- ostr << "\" name=\"LAMP" << i+1;
+ ostr << " name=\"LAMP" << i+1;
// color already premultiplied by energy, so only need distance here
float pwr = 1; // default for sun/hemi, distance irrelevant
if ((lamp->type!=LA_SUN) && (lamp->type!=LA_HEMI)) {
@@ -1709,16 +1719,58 @@ void yafrayFileRender_t::writeCamera()
void yafrayFileRender_t::writeHemilight()
{
+ World *world = G.scene->world;
+ bool fromAO = false;
+ if (R.r.GIquality==6){
+ // use Blender AO params is possible
+ if (world==NULL) return;
+ if ((world->mode & WO_AMB_OCC)==0) {
+ // no AO, use default GIquality
+ cout << "No ambient occlusion enabled\nUsing defaults of 25 samples & infinite distance instead" << endl;
+ }
+ else fromAO = true;
+ }
ostr.str("");
- ostr << "<light type=\"hemilight\" name=\"hemi_LT\" power=\"" << R.r.GIpower << "\"";
- switch (R.r.GIquality)
- {
- case 1 :
- case 2 : ostr << " samples=\"16\" >\n"; break;
- case 3 : ostr << " samples=\"36\" >\n"; break;
- case 4 : ostr << " samples=\"64\" >\n"; break;
- case 5 : ostr << " samples=\"128\" >\n"; break;
- default: ostr << " samples=\"25\" >\n";
+ if (R.r.GIcache) {
+ ostr << "<light type=\"pathlight\" name=\"path_LT\" power=\"" << R.r.GIpower << "\" mode=\"occlusion\"";
+ ostr << "\n\tcache=\"on\" use_QMC=\"on\" threshold=\"" << R.r.GIrefinement << "\" "
+ << "cache_size=\"" << ((2.0/float(R.r.xsch))*R.r.GIpixelspersample) << "\"";
+ ostr << "\n\tshadow_threshold=\"" << (1.0-R.r.GIshadowquality) << "\" grid=\"82\" search=\"35\"";
+ ostr << "\n\tignore_bumpnormals=\"" << (R.r.YF_nobump ? "on" : "off") << "\"";
+ if (fromAO) {
+ // for AO, with cache, using range of 32*1 to 32*16 seems good enough
+ ostr << "\n\tsamples=\"" << 32*world->aosamp << "\" maxdistance=\"" << world->aodist << "\" >\n";
+ }
+ else {
+ switch (R.r.GIquality)
+ {
+ case 1 : ostr << " samples=\"128\" >\n"; break;
+ case 2 : ostr << " samples=\"256\" >\n"; break;
+ case 3 : ostr << " samples=\"512\" >\n"; break;
+ case 4 : ostr << " samples=\"1024\" >\n"; break;
+ case 5 : ostr << " samples=\"2048\" >\n"; break;
+ default: ostr << " samples=\"256\" >\n";
+ }
+ }
+ }
+ else {
+ ostr << "<light type=\"hemilight\" name=\"hemi_LT\" power=\"" << R.r.GIpower << "\"";
+ if (fromAO) {
+ ostr << "\n\tsamples=\"" << world->aosamp*world->aosamp
+ << "\" maxdistance=\"" << world->aodist
+ << "\" use_QMC=\"" << ((world->aomode & WO_AORNDSMP) ? "off" : "on") << "\" >\n";
+ }
+ else {
+ switch (R.r.GIquality)
+ {
+ case 1 :
+ case 2 : ostr << " samples=\"16\" >\n"; break;
+ case 3 : ostr << " samples=\"36\" >\n"; break;
+ case 4 : ostr << " samples=\"64\" >\n"; break;
+ case 5 : ostr << " samples=\"128\" >\n"; break;
+ default: ostr << " samples=\"25\" >\n";
+ }
+ }
}
ostr << "</light>\n\n";
xmlfile << ostr.str();
@@ -1729,15 +1781,15 @@ void yafrayFileRender_t::writePathlight()
ostr.str("");
if (R.r.GIphotons)
{
- ostr << "<light type=\"globalphotonlight\" name=\"gpm\" photons=\""<<R.r.GIphotoncount<<"\""<<endl;
- ostr << "\tradius=\"" <<R.r.GIphotonradius << "\" depth=\""<< ((R.r.GIdepth>2) ? (R.r.GIdepth-1) : 1)
- << "\" caus_depth=\""<<R.r.GIcausdepth<< "\" search=\""<< R.r.GImixphotons<<"\" >"<<endl;
+ ostr << "<light type=\"globalphotonlight\" name=\"gpm\" photons=\"" << R.r.GIphotoncount << "\"" << endl;
+ ostr << "\tradius=\"" << R.r.GIphotonradius << "\" depth=\"" << ((R.r.GIdepth>2) ? (R.r.GIdepth-1) : 1)
+ << "\" caus_depth=\"" << R.r.GIcausdepth << "\" search=\"" << R.r.GImixphotons << "\" >"<<endl;
ostr << "</light>"<<endl;
}
ostr << "<light type=\"pathlight\" name=\"path_LT\" power=\"" << R.r.GIindirpower << "\"";
ostr << " depth=\"" << ((R.r.GIphotons) ? 1 : R.r.GIdepth) << "\" caus_depth=\"" << R.r.GIcausdepth <<"\"\n";
- if(R.r.GIdirect && R.r.GIphotons) ostr << "direct=\"on\"" << endl;
- if (R.r.GIcache && ! (R.r.GIdirect && R.r.GIphotons))
+ if (R.r.GIdirect && R.r.GIphotons) ostr << "direct=\"on\"" << endl;
+ if (R.r.GIcache && !(R.r.GIdirect && R.r.GIphotons))
{
switch (R.r.GIquality)
{
@@ -1748,10 +1800,11 @@ void yafrayFileRender_t::writePathlight()
case 5 : ostr << " samples=\"2048\" \n"; break;
default: ostr << " samples=\"512\" \n";
}
- float sbase = 2.0/float(R.r.xsch);
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";
+ ostr << "\tignore_bumpnormals=\"" << (R.r.YF_nobump ? "on" : "off") << "\"\n";
+ float sbase = 2.0/float(R.r.xsch);
+ ostr << "\tcache_size=\"" << sbase*R.r.GIpixelspersample << "\" shadow_threshold=\"" <<
+ 1.0-R.r.GIshadowquality << "\" grid=\"82\" search=\"35\" >\n";
}
else
{
@@ -1792,8 +1845,7 @@ bool yafrayFileRender_t::writeWorld()
if (BLI_testextensie(wimg->name, ".hdr")) {
ostr.str("");
ostr << "<background type=\"image\" name=\"world_background\" ";
- // since exposure adjust is an integer, using the texbri slider isn't actually very useful here (result either -1/0/1)
- // GIpower could be used, but is only active for GI
+ // 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";