diff options
-rw-r--r-- | source/blender/render/intern/source/pipeline.c | 40 | ||||
-rwxr-xr-x | source/blender/yafray/intern/export_File.cpp | 7 | ||||
-rw-r--r-- | source/blender/yafray/intern/export_Plugin.cpp | 11 |
3 files changed, 55 insertions, 3 deletions
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c index e03ddfb4931..a1fd1842488 100644 --- a/source/blender/render/intern/source/pipeline.c +++ b/source/blender/render/intern/source/pipeline.c @@ -61,6 +61,9 @@ #include "BSE_sequence.h" /* <----------------- bad!!! */ +/* yafray: include for yafray export/render */ +#include "YafRay_Api.h" + /* internal */ #include "render_types.h" #include "renderpipeline.h" @@ -71,6 +74,7 @@ #include "shadbuf.h" #include "zbuf.h" + /* render flow 1) Initialize state @@ -1588,6 +1592,37 @@ static void do_render_composite_fields_blur_3d(Render *re) re->display_draw(re->result, NULL); } +/* yafray: main yafray render/export call */ +static void yafrayRender(Render *re) +{ + + re->result= new_render_result(re, &re->disprect, 0, RR_USEMEM); + + /* yafray uses this global still..., also for database stage? */ + R= *re; + + // switch must be done before prepareScene() + if (!R.r.YFexportxml) + YAF_switchFile(); + else + YAF_switchPlugin(); + + printf("Starting scene conversion.\n"); + RE_Database_FromScene(re, re->scene, 1); + printf("Scene conversion done.\n"); + + /* yafray uses this global for exporting */ + R= *re; + + YAF_exportScene(); + RE_Database_Free(re); + +} + + +/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ + + /* main loop: doing sequence + fields + blur + 3d render + compositing */ static void do_render_all_options(Render *re) { @@ -1596,7 +1631,10 @@ static void do_render_all_options(Render *re) do_render_seq(re->result, re->r.cfra); } else { - do_render_composite_fields_blur_3d(re); + if(re->r.renderer==R_YAFRAY) + yafrayRender(re); + else + do_render_composite_fields_blur_3d(re); } } diff --git a/source/blender/yafray/intern/export_File.cpp b/source/blender/yafray/intern/export_File.cpp index d9124c902c2..dfd89eca722 100755 --- a/source/blender/yafray/intern/export_File.cpp +++ b/source/blender/yafray/intern/export_File.cpp @@ -289,6 +289,13 @@ void yafrayFileRender_t::displayImage() unsigned int idlen = (unsigned int)header[0]; if (idlen) fseek(fp, idlen, SEEK_CUR); + /* XXX how to get the image from Blender and write to it. This call doesn't allow to change buffer rects */ + RenderResult rres; + RE_GetResultImage(&R, &rres); + // rres.rectx, rres.recty is width/height + // rres.rectf is float buffer, scanlines starting in bottom + // rres.rectz is zbuffer, available when associated pass is set + // read data directly into buffer, picture is upside down for (unsigned short y=0;y<height;y++) { unsigned char* bpt = NULL; //(unsigned char*)R.rectot + ((((height-1)-y)*width)<<2); diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp index 26de34dd488..ab3c38cc795 100644 --- a/source/blender/yafray/intern/export_Plugin.cpp +++ b/source/blender/yafray/intern/export_Plugin.cpp @@ -274,8 +274,6 @@ void yafrayPluginRender_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) { @@ -292,6 +290,14 @@ void yafrayPluginRender_t::displayImage() unsigned int idlen = (unsigned int)header[0]; if (idlen) fseek(fp, idlen, SEEK_CUR); + /* XXX how to get the image from Blender and write to it. This call doesn't allow to change buffer rects */ + RenderResult rres; + RE_GetResultImage(&R, &rres); + // rres.rectx, rres.recty is width/height + // rres.rectf is float buffer, scanlines starting in bottom + // rres.rectz is zbuffer, available when associated pass is set + + // read data directly into buffer, picture is upside down for (unsigned short y=0;y<height;y++) { unsigned char* bpt = NULL;//(unsigned char*)R.rectot + ((((height-1)-y)*width)<<2); @@ -1948,6 +1954,7 @@ bool blenderYafrayOutput_t::putPixel(int x, int y, const yafray::color_t &c, out++; if (out==4096) { + /* XXX second arg is rcti *rect, allows to indicate sub-rect in image to draw */ R.display_draw(R.result, NULL); out = 0; } |