forked from bartvdbraak/blender
Added Simple Image Background Exporting for Yafray
Add an image texture to the world (in any channel, the first one with an image will be used) and it will be exported as an image background The texture 'bright' slider is connected to the 'power' variable If the image selected ends in hdr, it will be exported into an HDRI block. The texture 'bright' slider effects exposure adjust (it is slider value - 1) so a value of 1 == no expousre adjust. (this needs a better solution in a later implementation)
This commit is contained in:
parent
22d1a84968
commit
f5d3649d17
@ -1222,7 +1222,7 @@ void yafrayFileRender_t::writePathlight()
|
||||
bool yafrayFileRender_t::writeWorld()
|
||||
{
|
||||
World *world = G.scene->world;
|
||||
|
||||
short i=0,j=0;
|
||||
if (R.r.GIquality!=0) {
|
||||
if (R.r.GImethod==1) {
|
||||
if (world==NULL) cout << "WARNING: need world background for skydome!\n";
|
||||
@ -1233,6 +1233,42 @@ bool yafrayFileRender_t::writeWorld()
|
||||
|
||||
if (world==NULL) return false;
|
||||
|
||||
for(i=0;i<8;i++){
|
||||
if(world->mtex[i] != NULL){
|
||||
if(world->mtex[i]->tex->type == TEX_IMAGE && world->mtex[i]->tex->ima != NULL){
|
||||
|
||||
for(j=0;j<160;j++){
|
||||
if(world->mtex[i]->tex->ima->name[j] == '\0' && j > 3){
|
||||
if(
|
||||
(world->mtex[i]->tex->ima->name[j-3] == 'h' || world->mtex[i]->tex->ima->name[j-3] == 'H' ) &&
|
||||
(world->mtex[i]->tex->ima->name[j-2] == 'd' || world->mtex[i]->tex->ima->name[j-2] == 'D' ) &&
|
||||
(world->mtex[i]->tex->ima->name[j-1] == 'r' || world->mtex[i]->tex->ima->name[j-1] == 'R' )
|
||||
){
|
||||
ostr.str("");
|
||||
ostr << "<background type=\"HDRI\" name=\"world_background\" ";
|
||||
ostr << "exposure_adjust = \"";
|
||||
ostr << (world->mtex[i]->tex->bright-1) << "\"";
|
||||
ostr << " mapping = \"probe\" ";
|
||||
ostr << ">\n";
|
||||
ostr << "<filename value=\"" << world->mtex[i]->tex->ima->name << "\"/>\n";
|
||||
ostr << "</background>\n\n";
|
||||
xmlfile << ostr.str();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ostr.str("");
|
||||
ostr << "<background type=\"image\" name=\"world_background\" power=\"";
|
||||
ostr << world->mtex[i]->tex->bright << "\">\n";
|
||||
ostr << "<filename value=\"" << world->mtex[i]->tex->ima->name << "\"/>\n";
|
||||
ostr << "</background>\n\n";
|
||||
xmlfile << ostr.str();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ostr.str("");
|
||||
ostr << "<background type=\"constant\" name=\"world_background\" >\n";
|
||||
// if no GI used, the GIpower parameter is not always initialized, so in that case ignore it (have to change method to init yafray vars in Blender)
|
||||
|
Loading…
Reference in New Issue
Block a user