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:
-rw-r--r--source/blender/render/intern/source/initrender.c9
-rw-r--r--source/blender/yafray/intern/export_Plugin.cpp35
2 files changed, 29 insertions, 15 deletions
diff --git a/source/blender/render/intern/source/initrender.c b/source/blender/render/intern/source/initrender.c
index 3bc6423153a..8d975adfc85 100644
--- a/source/blender/render/intern/source/initrender.c
+++ b/source/blender/render/intern/source/initrender.c
@@ -746,14 +746,20 @@ void add_to_blurbuf(int blur)
void yafrayRender()
{
R.flag |= R_RENDERING; /* !!! */
+
+ if (R.rectz) MEM_freeN(R.rectz);
+ R.rectz = 0;
+
// switch must be done before prepareScene()
if (!R.r.YFexportxml)
YAF_switchFile();
else
YAF_switchPlugin();
+
printf("Starting scene conversion.\n");
prepareScene();
printf("Scene conversion done.\n");
+
YAF_exportScene();
finalizeScene();
}
@@ -764,9 +770,8 @@ void render() {
/* yafray: render, see above */
if (R.r.renderer==R_YAFRAY)
yafrayRender();
- else {
+ else
oldRenderLoop();
- }
}
diff --git a/source/blender/yafray/intern/export_Plugin.cpp b/source/blender/yafray/intern/export_Plugin.cpp
index 11a54fa858d..a46f30b4be1 100644
--- a/source/blender/yafray/intern/export_Plugin.cpp
+++ b/source/blender/yafray/intern/export_Plugin.cpp
@@ -185,21 +185,20 @@ bool yafrayPluginRender_t::initExport()
cout<<"YafRay plugin loaded"<<endl;
}
- if(R.rectot == NULL)
+ 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;
+ }
- for (unsigned short y=0;y<R.recty;y++) {
- unsigned char* bpt = (unsigned char*)R.rectot + ((((R.recty-1)-y)*R.rectx)<<2);
- for (unsigned short x=0;x<R.rectx;x++) {
- bpt[2] = 128;
- bpt[1] = 0;
- bpt[0] = 0;
- bpt[3] = 255;
- bpt += 4;
- }
+ 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;
}
-
- cout<<"Image allocated"<<endl;
+
return true;
}
@@ -1261,7 +1260,6 @@ void yafrayPluginRender_t::writeAreaLamp(LampRen* lamp, int num, float iview[4][
// transform area lamp coords back to world
float lpco[4][3];
- MTC_Mat4Invert(iview, R.viewmat);
MTC_cp3Float(a, lpco[0]);
MTC_Mat4MulVecfl(iview, lpco[0]);
MTC_cp3Float(b, lpco[1]);
@@ -1663,6 +1661,17 @@ bool blenderYafrayOutput_t::putPixel(int x, int y,const yafray::color_t &c,
temp=(int)(alpha*255.0+0.5);
if(temp>255) temp=255;
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);
+ }
+
out++;
if(out==4096)
{