fixed problem with ray button and shadow rendering

Blender 'sphere' mode lights in yafray should now have more similar light levels
render shadow button in Blender must now be enabled to render shadows in yafray too
some other minor shadow related corrections
This commit is contained in:
Alfredo de Greef 2004-01-27 00:15:12 +00:00
parent a5f2e598a2
commit 8273ebce0f
2 changed files with 14 additions and 9 deletions

@ -1807,13 +1807,17 @@ void RE_add_render_lamp(Object *ob, int doshadbuf)
} }
} }
/* to make sure we can check ray shadow easily in the render code */ /* yafray: shadow flag should not be cleared, only used with internal renderer */
if(lar->mode & LA_SHAD_RAY) { if ((R.r.mode & R_YAFRAY)==0) {
if( (R.r.mode & R_RAYTRACE)==0) /* to make sure we can check ray shadow easily in the render code */
lar->mode &= ~LA_SHAD_RAY; if(lar->mode & LA_SHAD_RAY) {
if( (R.r.mode & R_RAYTRACE)==0)
lar->mode &= ~LA_SHAD_RAY;
}
} }
lar->org= MEM_dupallocN(lar); lar->org= MEM_dupallocN(lar);
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */

@ -1007,11 +1007,10 @@ void yafrayFileRender_t::writeAreaLamp(LampRen* lamp, int num)
ostr << "<light type=\"arealight\" name=\"LAMP" << num+1 << "\" dummy=\""<< md << "\" power=\"" << lamp->energy << "\" "; ostr << "<light type=\"arealight\" name=\"LAMP" << num+1 << "\" dummy=\""<< md << "\" power=\"" << lamp->energy << "\" ";
if (!R.r.GIphotons) { if (!R.r.GIphotons) {
int psm=0, sm = lamp->ray_totsamp; int psm=0, sm = lamp->ray_totsamp;
if (sm>=16) psm = sm/4; if (sm>=64) psm = sm/4;
ostr << "samples=\"" << sm << "\" psamples=\"" << psm << "\" "; ostr << "samples=\"" << sm << "\" psamples=\"" << psm << "\" ";
} }
ostr << ">\n"; ostr << ">\n";
ostr << "\t<a x=\""<< a[0] <<"\" y=\""<< a[1] <<"\" z=\"" << a[2] <<"\" />\n"; ostr << "\t<a x=\""<< a[0] <<"\" y=\""<< a[1] <<"\" z=\"" << a[2] <<"\" />\n";
ostr << "\t<b x=\""<< b[0] <<"\" y=\""<< b[1] <<"\" z=\"" << b[2] <<"\" />\n"; ostr << "\t<b x=\""<< b[0] <<"\" y=\""<< b[1] <<"\" z=\"" << b[2] <<"\" />\n";
ostr << "\t<c x=\""<< c[0] <<"\" y=\""<< c[1] <<"\" z=\"" << c[2] <<"\" />\n"; ostr << "\t<c x=\""<< c[0] <<"\" y=\""<< c[1] <<"\" z=\"" << c[2] <<"\" />\n";
@ -1046,8 +1045,8 @@ void yafrayFileRender_t::writeLamps()
// color already premultiplied by energy, so only need distance here // color already premultiplied by energy, so only need distance here
float pwr; float pwr;
if (lamp->mode & LA_SPHERE) { if (lamp->mode & LA_SPHERE) {
// best approx. as used in LFexport script, however, in yafray it seems incorrect, so LF must use another model // best approx. as used in LFexport script (LF d.f.m. 4pi?)
pwr = lamp->dist*(lamp->dist+1)*0.125; pwr = lamp->dist*(lamp->dist+1)*0.25*M_1_PI;
//decay = 2; //decay = 2;
} }
else { else {
@ -1059,7 +1058,9 @@ void yafrayFileRender_t::writeLamps()
} }
ostr << "\" power=\"" << pwr; ostr << "\" power=\"" << pwr;
string lpmode="off"; string lpmode="off";
if ((lamp->mode & LA_SHAD) || (lamp->mode & LA_SHAD_RAY)) lpmode="on";; // shadows only when Blender has shadow button enabled, only spots use LA_SHAD flag
if (R.r.mode & R_SHADOW)
if (((lamp->type==LA_SPOT) && (lamp->mode & LA_SHAD)) || (lamp->mode & LA_SHAD_RAY)) lpmode="on";;
ostr << "\" cast_shadows=\"" << lpmode << "\""; ostr << "\" cast_shadows=\"" << lpmode << "\"";
// spot specific stuff // spot specific stuff
if (lamp->type==LA_SPOT) { if (lamp->type==LA_SPOT) {