diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/render/intern/source/initrender.c | 16 | ||||
-rwxr-xr-x | source/blender/yafray/intern/export_File.cpp | 11 | ||||
-rw-r--r-- | source/blender/yafray/intern/export_Plugin.cpp | 69 |
3 files changed, 60 insertions, 36 deletions
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c index b4edee17bb6..dbecb9fecb2 100644 --- a/source/blender/render/intern/source/initrender.c +++ b/source/blender/render/intern/source/initrender.c @@ -820,8 +820,16 @@ void yafrayRender() { R.flag |= R_RENDERING; /* !!! */ + /* all allocs moved here, out of export code */ + /* display rgba buf */ + if (R.rectot) MEM_freeN(R.rectot); + R.rectot = MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot"); + /* zbuf */ if (R.rectz) MEM_freeN(R.rectz); - R.rectz = NULL; + R.rectz = (unsigned int *)MEM_mallocN(sizeof(int)*R.rectx*R.recty, "rectz"); + /* float rgba buf */ + if (R.rectftot) MEM_freeN(R.rectftot); + if (R.r.mode & R_FBUF) R.rectftot= MEM_callocN(4*sizeof(float)*R.rectx*R.recty, "rectftot"); // switch must be done before prepareScene() if (!R.r.YFexportxml) @@ -835,6 +843,12 @@ void yafrayRender() YAF_exportScene(); finalizeScene(); + + // show postpro effects if floatbuffer used (plugin only) + if (R.r.YFexportxml) { + if ((R.r.mode & R_FBUF) && R.rectftot) + RE_floatbuffer_to_output(); + } } diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp index 43b4f6298e9..b865096477a 100755 --- a/source/blender/yafray/intern/export_File.cpp +++ b/source/blender/yafray/intern/export_File.cpp @@ -119,8 +119,12 @@ bool yafrayFileRender_t::initExport() // try the user setting setting first, export dir must be set and exist if (strlen(U.yfexportdir)==0) { - cout << "No export directory set in user defaults!\n"; - dir_failed = true; + cout << "No export directory set in user defaults!" << endl; + char* temp = getenv("TEMP"); + // if no envar, use /tmp + xmlpath = temp ? temp : "/tmp"; + cout << "Will try TEMP instead: " << xmlpath << endl; + // no fail here, but might fail when opening file... } else { @@ -256,9 +260,6 @@ void yafrayFileRender_t::displayImage() // although it is possible to load the image using blender, // maybe it is best to just do a read here, for now the yafray output is always a raw tga anyway - // rectot already freed in initrender - R.rectot = (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot"); - FILE* fp = fopen(imgout.c_str(), "rb"); if (fp==NULL) { cout << "YAF_displayImage(): Could not open image file\n"; diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp index 5463016ea65..79286429b7a 100644 --- a/source/blender/yafray/intern/export_Plugin.cpp +++ b/source/blender/yafray/intern/export_Plugin.cpp @@ -189,20 +189,18 @@ bool yafrayPluginRender_t::initExport() plugin_loaded = true; } - if (R.rectot==NULL) { - R.rectot = (unsigned int *)MEM_callocN(sizeof(int)*R.rectx*R.recty, "rectot"); - unsigned int *bpt=R.rectot, count=R.rectx*R.recty; - while (--count) bpt[count] = 0xff800000; - cout << "Image allocated" << endl; - } + // all buffers allocated in initrender.c + unsigned int *bpt=R.rectot, count=R.rectx*R.recty; + while (--count) bpt[count] = 0xff800000; + cout << "Image initialized" << endl; - if (R.rectz==NULL) { - R.rectz = (unsigned int *)MEM_mallocN(sizeof(int)*R.rectx*R.recty, "rectz"); - unsigned int *zbuf=R.rectz, count=R.rectx*R.recty; - while (--count) zbuf[count] = 0x7fffffff; - cout << "Zbuffer allocated" << endl; - } + unsigned int *zbuf=R.rectz; + count = R.rectx*R.recty; + while (--count) zbuf[count] = 0x7fffffff; + cout << "Zbuffer initialized" << endl; + // no need to fill ftot + return true; } @@ -1690,30 +1688,41 @@ bool yafrayPluginRender_t::writeWorld() #include "RE_callbacks.h" -bool blenderYafrayOutput_t::putPixel(int x, int y,const yafray::color_t &c, - yafray::CFLOAT alpha,yafray::PFLOAT depth) +bool blenderYafrayOutput_t::putPixel(int x, int y, const yafray::color_t &c, + yafray::CFLOAT alpha, yafray::PFLOAT depth) { - unsigned char* bpt = (unsigned char*)R.rectot + ((((R.recty-1)-y)*R.rectx)<<2); - int temp=(int)(c.R*255.0+0.5); - if(temp>255) temp=255; - bpt[4*x]=temp; - temp=(int)(c.G*255.0+0.5); - if(temp>255) temp=255; - bpt[4*x+1]=temp; - temp=(int)(c.B*255.0+0.5); - if(temp>255) temp=255; - bpt[4*x+2]=temp; - temp=(int)(alpha*255.0+0.5); - if(temp>255) temp=255; - bpt[4*x+3]=temp; + unsigned int px = ((R.recty-1)-y)*R.rectx; + unsigned char* bpt = (unsigned char*)R.rectot + (px<<2); + int x4 = x<<2; + int temp = (int)(c.R*255.f+0.5f); + if (temp>255) temp=255; + bpt[x4] = temp; + temp=(int)(c.G*255.f+0.5f); + if (temp>255) temp=255; + bpt[x4+1] = temp; + temp=(int)(c.B*255.f+0.5f); + if (temp>255) temp=255; + bpt[x4+2] = temp; + temp=(int)(alpha*255.f+0.5f); + if (temp>255) temp=255; + bpt[x4+3] = temp; + + // float buffer + if ((R.r.mode & R_FBUF) && R.rectftot) { + float* fpt = R.rectftot + (px<<2); + fpt[x4] = c.R; + fpt[x4+1] = c.G; + fpt[x4+2] = c.B; + fpt[x4+3] = alpha; + } // depth values - unsigned int* zbuf = R.rectz + ((R.recty-1)-y)*R.rectx; + unsigned int* zbuf = R.rectz + px; 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); + if (mz!=0.f) mz = 2147483647.f/mz; + zbuf[x] = (unsigned int)(depth*mz); out++; if(out==4096) |