diff options
Diffstat (limited to 'source/blender/yafray')
-rwxr-xr-x | source/blender/yafray/intern/export_File.cpp | 89 | ||||
-rw-r--r-- | source/blender/yafray/intern/export_Plugin.cpp | 136 | ||||
-rw-r--r-- | source/blender/yafray/intern/yafray_Render.cpp | 2 |
3 files changed, 148 insertions, 79 deletions
diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp index 49811c5a336..e80c5362baf 100755 --- a/source/blender/yafray/intern/export_File.cpp +++ b/source/blender/yafray/intern/export_File.cpp @@ -1,4 +1,4 @@ -#include"export_File.h" +#include "export_File.h" #include <math.h> @@ -8,7 +8,7 @@ static string command_path = ""; #ifdef WIN32 -#include<windows.h> +#include <windows.h> #ifndef FILE_MAXDIR #define FILE_MAXDIR 160 @@ -345,8 +345,7 @@ void yafrayFileRender_t::writeTextures() // used to keep track of images already written // (to avoid duplicates if also in imagetex for material TexFace texture) set<Image*> dupimg; - - string ts; + for (map<string, MTex*>::const_iterator blendtex=used_textures.begin(); blendtex!=used_textures.end();++blendtex) { MTex* mtex = blendtex->second; @@ -357,17 +356,29 @@ void yafrayFileRender_t::writeTextures() // noisebasis type string ntype = noise2string(tex->noisebasis); + string ts, hardnoise=(tex->noisetype==TEX_NOISESOFT) ? "off" : "on"; switch (tex->type) { case TEX_STUCCI: - // stucci is clouds as bump, but could be added to yafray to handle both wall in/out as well. - // noisedepth must be at least 1 in yafray + // stucci is clouds as bump, only difference is an extra parameter to handle wall in/out + // turbulence value is not used, so for large values will not match well case TEX_CLOUDS: { ostr.str(""); ostr << "<shader type=\"clouds\" name=\"" << blendtex->first << "\" >\n"; ostr << "\t<attributes>\n"; - ostr << "\t\t<depth value=\"" << tex->noisedepth+1 << "\" />\n"; ostr << "\t\t<size value=\"" << nsz << "\" />\n"; + ostr << "\t\t<hard value=\"" << hardnoise << "\" />\n"; + if (tex->type==TEX_STUCCI) { + if (tex->stype==1) + ts = "positive"; + else if (tex->stype==2) + ts = "negative"; + else ts = "none"; + ostr << "\t\t<bias value=\"" << ts << "\" />\n"; + ostr << "\t\t<depth value=\"0\" />\n"; // for stucci always 0 + } + else ostr << "\t\t<depth value=\"" << tex->noisedepth << "\" />\n"; + ostr << "\t\t<color_type value=\"" << tex->stype << "\" />\n"; ostr << "\t\t<noise_type value=\"" << ntype << "\" />\n"; ostr << "\t</attributes>\n</shader >\n\n"; xmlfile << ostr.str(); @@ -377,13 +388,15 @@ void yafrayFileRender_t::writeTextures() ostr.str(""); ostr << "<shader type=\"wood\" name=\"" << blendtex->first << "\" >\n"; ostr << "\t\t<attributes>\n"; - ostr << "\t\t<depth value=\"" << tex->noisedepth+1 << "\" />\n"; - ostr << "\t\t<turbulence value=\"" << tex->turbul << "\" />\n"; - ostr << "\t\t<ringscale_x value=\"" << mtex->size[0] << "\" />\n"; - ostr << "\t\t<ringscale_y value=\"" << mtex->size[1] << "\" />\n"; - ts = "on"; - if (tex->noisetype==TEX_NOISESOFT) ts = "off"; - ostr << "\t\t<hard value=\"" << ts << "\" />\n"; + // blender does not use depth value for wood, always 0 + ostr << "\t\t<depth value=\"0\" />\n"; + float turb = (tex->stype<2) ? 0.0 : tex->turbul; + ostr << "\t\t<turbulence value=\"" << turb << "\" />\n"; + ostr << "\t\t<size value=\"" << nsz << "\" />\n"; + ostr << "\t\t<hard value=\"" << hardnoise << "\" />\n"; + ts = (tex->stype & 1) ? "rings" : "bands"; //stype 1&3 ringtype + ostr << "\t\t<wood_type value=\"" << ts << "\" />\n"; + ostr << "\t\t<noise_type value=\"" << ntype << "\" />\n"; ostr << "\t</attributes>\n</shader>\n\n"; xmlfile << ostr.str(); break; @@ -392,14 +405,12 @@ void yafrayFileRender_t::writeTextures() ostr.str(""); ostr << "<shader type=\"marble\" name=\"" << blendtex->first << "\" >\n"; ostr << "\t<attributes>\n"; - ostr << "\t\t<depth value=\"" << tex->noisedepth+1 << "\" />\n"; + ostr << "\t\t<depth value=\"" << tex->noisedepth << "\" />\n"; ostr << "\t\t<turbulence value=\"" << tex->turbul << "\" />\n"; - ts = "on"; - if (tex->noisetype==TEX_NOISESOFT) ts = "off"; - ostr << "\t\t<hard value=\"" << ts << "\" />\n"; - ts = "1"; - if (tex->stype==1) ts="5"; else if (tex->stype==2) ts="10"; - ostr << "\t\t<sharpness value=\"" << ts << "\" />\n"; + ostr << "\t\t<size value=\"" << nsz << "\" />\n"; + ostr << "\t\t<hard value=\"" << hardnoise << "\" />\n"; + ostr << "\t\t<sharpness value=\"" << (float)(1<<tex->stype) << "\" />\n"; + ostr << "\t\t<noise_type value=\"" << ntype << "\" />\n"; ostr << "\t</attributes>\n</shader>\n\n"; xmlfile << ostr.str(); break; @@ -490,6 +501,35 @@ void yafrayFileRender_t::writeTextures() xmlfile << ostr.str(); break; } + case TEX_BLEND: { + ostr.str(""); + ostr << "<shader type=\"gradient\" name=\"" << blendtex->first << "\" >\n"; + ostr << "\t<attributes>\n"; + switch (tex->stype) { + case 1: ts="quadratic"; break; + case 2: ts="cubic"; break; + case 3: ts="diagonal"; break; + case 4: ts="sphere"; break; + case 5: ts="halo"; break; + default: + case 0: ts="linear"; break; + } + ostr << "\t\t<gradient_type value=\"" << ts << "\" />\n"; + if (tex->flag & TEX_FLIPBLEND) ts="on"; else ts="off"; + ostr << "\t\t<flip_xy value=\"" << ts << "\" />\n"; + ostr << "\t</attributes>\n</shader>\n\n"; + xmlfile << ostr.str(); + break; + } + case TEX_NOISE: { + ostr.str(""); + ostr << "<shader type=\"random_noise\" name=\"" << blendtex->first << "\" >\n"; + ostr << "\t<attributes>\n"; + ostr << "\t\t<depth value=\"" << tex->noisedepth << "\" />\n"; + ostr << "\t</attributes>\n</shader>\n\n"; + xmlfile << ostr.str(); + break; + } case TEX_IMAGE: { Image* ima = tex->ima; if (ima) { @@ -664,9 +704,10 @@ void yafrayFileRender_t::writeShader(const string &shader_name, Material* matr, // bumpmapping if ((mtex->mapto & MAP_NORM) || (mtex->maptoneg & MAP_NORM)) { - // for yafray, bump factor is negated (unless negative option of 'Nor', is not affected by 'Neg') - // scaled down quite a bit for yafray - float nf = -mtex->norfac; + // for yafray, bump factor is negated (unless tex is stucci, not affected by 'Neg') + // scaled down quite a bit + float nf = mtex->norfac; + if (tex->type!=TEX_STUCCI) nf *= -1.f; if (mtex->maptoneg & MAP_NORM) nf *= -1.f; ostr << "\t\t<normal value=\"" << (nf/60.f) << "\" />\n"; diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp index 9a511cc5d7c..5d58612bc4d 100644 --- a/source/blender/yafray/intern/export_Plugin.cpp +++ b/source/blender/yafray/intern/export_Plugin.cpp @@ -1,4 +1,4 @@ -#include"export_Plugin.h" +#include "export_Plugin.h" #include <math.h> using namespace std; @@ -6,7 +6,7 @@ using namespace std; #ifdef WIN32 -#include<windows.h> +#include <windows.h> #ifndef FILE_MAXDIR #define FILE_MAXDIR 160 @@ -349,7 +349,6 @@ void yafrayPluginRender_t::writeTextures() // (to avoid duplicates if also in imagetex for material TexFace texture) set<Image*> dupimg; - string ts; yafray::paramMap_t params; list<yafray::paramMap_t> lparams; for (map<string, MTex*>::const_iterator blendtex=used_textures.begin(); @@ -366,59 +365,53 @@ void yafrayPluginRender_t::writeTextures() // noisebasis type string ntype = noise2string(tex->noisebasis); + string ts, hardnoise=(tex->noisetype==TEX_NOISESOFT) ? "off" : "on"; switch (tex->type) { case TEX_STUCCI: - // stucci is clouds as bump, but could be added to yafray to handle both wall in/out as well. - // noisedepth must be at least 1 in yafray + // stucci is clouds as bump, only difference is an extra parameter to handle wall in/out + // turbulence value is not used, so for large values will not match well case TEX_CLOUDS: { params["type"] = yafray::parameter_t("clouds"); - params["depth"] = yafray::parameter_t(tex->noisedepth+1); params["size"] = yafray::parameter_t(nsz); - params["noise_type"] = ntype; + params["hard"] = yafray::parameter_t(hardnoise); + if (tex->type==TEX_STUCCI) { + if (tex->stype==1) + ts = "positive"; + else if (tex->stype==2) + ts = "negative"; + else ts = "none"; + params["bias"] = yafray::parameter_t(ts); + params["depth"] = yafray::parameter_t(0); // for stucci always 0 + } + else params["depth"] = yafray::parameter_t(tex->noisedepth); + params["color_type"] = yafray::parameter_t(tex->stype); + params["noise_type"] = yafray::parameter_t(ntype); break; } case TEX_WOOD: { params["type"] = yafray::parameter_t("wood"); - params["depth"] = yafray::parameter_t(tex->noisedepth+1); - params["turbulence"] = yafray::parameter_t(tex->turbul); - params["ringscale_x"] = yafray::parameter_t(mtex->size[0]); - params["ringscale_y"] = yafray::parameter_t(mtex->size[1]); - ts = "on"; - if (tex->noisetype==TEX_NOISESOFT) ts = "off"; - params["hard"] = yafray::parameter_t(ts); + // blender does not use depth value for wood, always 0 + params["depth"] = yafray::parameter_t(0); + float turb = (tex->stype<2) ? 0.0 : tex->turbul; + params["turbulence"] = yafray::parameter_t(turb); + params["size"] = yafray::parameter_t(nsz); + params["hard"] = yafray::parameter_t(hardnoise); + ts = (tex->stype & 1) ? "rings" : "bands"; //stype 1&3 ringtype + params["wood_type"] = yafray::parameter_t(ts); + params["noise_type"] = yafray::parameter_t(ntype); break; } case TEX_MARBLE: { - params["type"]=yafray::parameter_t("marble"); - params["depth"]=yafray::parameter_t(tex->noisedepth+1); - params["turbulence"]=yafray::parameter_t(tex->turbul); - ts = "on"; - if (tex->noisetype==TEX_NOISESOFT) ts = "off"; - params["hard"]=yafray::parameter_t(ts); - if (tex->stype==1) - params["sharpness"]=yafray::parameter_t(5); - else if (tex->stype==2) - params["sharpness"]=yafray::parameter_t(10); - else - params["sharpness"]=yafray::parameter_t(1); - break; - } - case TEX_IMAGE: - { - Image* ima = tex->ima; - if (ima) { - // remember image to avoid duplicates later if also in imagetex - // (formerly done by removing from imagetex, but need image/material link) - dupimg.insert(ima); - params["type"] = yafray::parameter_t("image"); - params["name"] = yafray::parameter_t(ima->id.name); - string texpath = ima->name; - adjustPath(texpath); - params["filename"] = yafray::parameter_t(texpath); - } + params["type"] = yafray::parameter_t("marble"); + params["depth"] = yafray::parameter_t(tex->noisedepth); + params["turbulence"] = yafray::parameter_t(tex->turbul); + params["size"] = yafray::parameter_t(nsz); + params["hard"] = yafray::parameter_t(hardnoise); + params["sharpness"] = yafray::parameter_t((float)(1<<tex->stype)); + params["noise_type"] = yafray::parameter_t(ntype); break; } case TEX_VORONOI: @@ -496,6 +489,45 @@ void yafrayPluginRender_t::writeTextures() params["size"] = yafray::parameter_t(nsz); params["noise_type1"] = yafray::parameter_t(ntype); params["noise_type2"] = yafray::parameter_t(noise2string(tex->noisebasis2)); + break; + } + case TEX_BLEND: + { + params["type"] = yafray::parameter_t("gradient"); + switch (tex->stype) { + case 1: ts="quadratic"; break; + case 2: ts="cubic"; break; + case 3: ts="diagonal"; break; + case 4: ts="sphere"; break; + case 5: ts="halo"; break; + default: + case 0: ts="linear"; break; + } + params["gradient_type"] = yafray::parameter_t(ts); + if (tex->flag & TEX_FLIPBLEND) ts="on"; else ts="off"; + params["flip_xy"] = yafray::parameter_t(ts); + break; + } + case TEX_NOISE: + { + params["type"] = yafray::parameter_t("random_noise"); + params["depth"] = yafray::parameter_t(tex->noisedepth); + break; + } + case TEX_IMAGE: + { + Image* ima = tex->ima; + if (ima) { + // remember image to avoid duplicates later if also in imagetex + // (formerly done by removing from imagetex, but need image/material link) + dupimg.insert(ima); + params["type"] = yafray::parameter_t("image"); + params["name"] = yafray::parameter_t(ima->id.name); + string texpath = ima->name; + adjustPath(texpath); + params["filename"] = yafray::parameter_t(texpath); + } + break; } default: cout << "Unsupported texture type\n"; @@ -651,10 +683,10 @@ void yafrayPluginRender_t::writeShader(const string &shader_name, Material* matr // bumpmapping if ((mtex->mapto & MAP_NORM) || (mtex->maptoneg & MAP_NORM)) { - // for yafray, bump factor is negated (unless negative option of 'Nor', - // is not affected by 'Neg') - // scaled down quite a bit for yafray - float nf = -mtex->norfac; + // for yafray, bump factor is negated (unless tex is stucci, not affected by 'Neg') + // scaled down quite a bit + float nf = mtex->norfac; + if (tex->type!=TEX_STUCCI) nf *= -1.f; if (mtex->maptoneg & MAP_NORM) nf *= -1.f; mparams["normal"] = yafray::parameter_t(nf/60.f); } @@ -1668,14 +1700,12 @@ bool blenderYafrayOutput_t::putPixel(int x, int y,const yafray::color_t &c, bpt[4*x+3]=temp; // depth values - if (R.rectz) { - unsigned int* zbuf = R.rectz + ((R.recty-1)-y)*R.rectx; - depth -= R.near; - float mz = R.far - R.near; - if (depth<0) depth=0; else if (depth>mz) depth=mz; - if (mz!=0.f) mz = 1.f/mz; - zbuf[x] = (unsigned int)(depth*mz*2147483647.f); - } + unsigned int* zbuf = R.rectz + ((R.recty-1)-y)*R.rectx; + depth -= R.near; + float mz = R.far - R.near; + if (depth<0) depth=0; else if (depth>mz) depth=mz; + if (mz!=0.f) mz = 1.f/mz; + zbuf[x] = (unsigned int)(depth*mz*2147483647.f); out++; if(out==4096) diff --git a/source/blender/yafray/intern/yafray_Render.cpp b/source/blender/yafray/intern/yafray_Render.cpp index 400f06e5c79..d80bbf0de6c 100644 --- a/source/blender/yafray/intern/yafray_Render.cpp +++ b/source/blender/yafray/intern/yafray_Render.cpp @@ -106,8 +106,6 @@ bool yafrayRender_t::getAllMatTexObs() // if texture type not available in yafray, ignore if ((txtp==0) || (txtp==TEX_MAGIC) || - (txtp==TEX_BLEND) || - (txtp==TEX_NOISE) || (txtp==TEX_PLUGIN) || (txtp==TEX_ENVMAP)) continue; // In the case of an image texture, check that there is an actual image, otherwise ignore. |